Consulting

Results 1 to 15 of 15

Thread: Help me please...

  1. #1

    Help me please...

    Dear All Experts,

    Has anyone could help me please. I create a debit / credit table in a word document using blank fields inside rows to be filled out on the VBA. The shymptom is like this, if I click each radio button (DEBIT) then it will write on each Field "DEBIT" on the word document, if I click on CREDIT radio button, it will write "CREDIT" or if I leave it blank, it will do nothing (result is a blank field). Anyone knows how to code this problem please...please...I was really stack to think about this..

    Since this forum could not attach .DOC file, I can send to you the file to your whatever email addresses, etc for your reviews and helps...

    Thank you very much for your fully kind assistance and helps...

    Jennifer

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi Jennifer,
    It would definitely help if you could upload your example. The problem is it must be zipped up. If you can't zip it up before attaching it to your post send me a private message and I will help you get it uploaded.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Hi...Thanks for your kind helps...Please find my attached zipped file.

  4. #4
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    This is easy to do. However, you need to be clear in WHAT you want to do. I have downloaded the file.

    1. You have no event to actually show the UserForm. Something that will sactually display the userform. I have made it on Document_Open.

    2. You have "radio" buttons. It is more accurate to call them Option buttons. Option buttons are most useful on a form if they are used as clear Yes/No Either/Or choices. If you put them in a frame, the user can ONLY pick one, or the other.

    3. You have a listing of Credit - Debit on three lines - presumably to match the three fields in the document. You could in fact use only one pair.

    4. You are using formfields in the table. I love formfields, but I have to ask why you are using them here. You could just as easily make the text in the cells "Credit" or "Debit". Formfields are not needed. Formfields are, generally, for user input. In this case, YOU are putting the text in the location. Unless you have a reason to, just use text rather than formfield.

    5. Do not use the default names for objects. OptionButton1 tells you nothing.

    6. It would help if you expand on your intentions. What are you trying to do?

    You need to actually WRITE out your logic. You have six OptionButtons on your form. If OptionButton1 = True (it is picked)...what do you want to happen??? Should formfield("bookamrk1) be "Credit" or Debit"...or maybe it is formfields("bookmark2")...should IT be "Credit"...oh, maybe it should be "Debit". Or is it bookmark3...but is it "credit" or "Debit". You MUST write out EXACTLY what the logic is. What do you want to happen, and it has to be precisely, each little step. Programming will (generally) do exactly what you tell it to do. So if you do not tell it something, it will not do it, or if you tell it to do something you do not want - too bad - it will do what you tell it to do. It will NEVER do something you want it to do without you instructing it to do that. It will NEVER read your mind. That is what you need to map out precisely what you want.

    To answer your direct question though:
    [vba]If OptionButton1 = True Then _
    ActiveDocument.Formfields("bookmark1").Result = "Debit"[/vba]
    But this is BAD programming.

  5. #5
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Hmmmm, I see another post. md seems to have discovered this is an assignment, although how did you do that?

    He is correct. If this IS an assignment, we can not help you with a solution. Good thing I looked at the other post. I had actually quickly made it a lot better, and was going to post back. This I can't do now. We will help with guidance if you have a specific coding problem.

  6. #6
    Dear Gerry,

    Thanks for your reply and helps.

    I mean, I just create the dummy for your reviews....the shymtom is like this:

    There is a debit radio button on the left side and credit on the right side, right?

    If I click on debit side, it will write on the bookmarked field "DEBIT" text and in other side, if I click on credit side, it will overwrite the bookmarked field with "CREDIT"...

    Do you know the code for this please? Please I need your help...

    Dont worry about showing the form...

    Thanks very much,

    Jennifer

  7. #7
    Hi Gerry,

    The meaning of assignment is not the assignment for university...my father give me task to do something with word documentation/template for his small shop...Please, just want to let you know..this is not the uni assignment...ok, I think I spell it wrong...hmm...ok, this my task from my father, I just want to help him to prepare his document...Please help me...

  8. #8
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Yes, I do know the code for this very well. I can do this in my sleep. But you know what....no, I will not help you. You must help yourself on this. I asked some questions, and I would have helped you, but I am very tired of trying to help people who do not answer questions, who ask the same question over and over agin, and really....do not seem to read posts very well.

    I made suggestions, I asked serious questions to try and help you....but you obviously are not reading them. I even gave a line of code that would, in fact, write the text in as you asked.

    You are looking for an easy solution without doing anything, either that or you are not really paying any attention to what I wrote. Why should I bother? I wrote a attentive response, and it sure seems you did not pay any attention to it.

    So....no.

    Good luck.

  9. #9
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location

    Anyone could help me please how to do this..???...I almost 2 weeks got stack about this....Please help me for my assignment.....

    Hi Gerry,
    This gave me a clue!
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  10. #10
    What 's wrong with all of you guys...????....If this forum does provide helps...then just close this forum huh..???...I know you are an expert, but dont be underestimate me...I am a newbie, and I really dont know about that part only...the rest of project I had already made it...I already tried within 2 weeks for this codes but I was gave up...that is why I come to you guys....please be polite...I came here nicely...so be polite if someone asking and need helps...

    Thanks..

  11. #11
    Hi MD,

    Sorry I was little bit upset...however, thanks for continuing to help me...the file is in my father's office...so, I will send the whole codes on monday....I already try with your codes actually before you complaint to me BUT the field was gone. For Instance, if I clicked on radio button on "DEBIT" it wrote "DEBIT" but if I change to the CREDIT, the grey bookmark field was gone and it still kept "DEBIT"....I will send the file on Monday...I did the code like this:

    [VBA]

    If OptionDebit = True Then _
    ActiveDocument.Formfields("bookmark1").Result = "Debit"
    End If

    If OptionCredit = True Then
    ActiveDocument.Formfields("bookmark1").Result = "Credit"
    EndIf



    [/VBA]

    I know my codes are messy and were so BAD code design...because I am just learner and learner...I am really a new beginner...

    Thanks,

    Jennifer

  12. #12
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Send us the file. At least you are trying.

    I would wish you to answer my questions. Something, or someone, told you to use formfields. Why? better yet - I ask again - what are you trying to do?

  13. #13
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Oh, and post ALL your code. The code posted above will not do anything in isolation. We need to see what you are doing. Don't be shy. We want to see what you are doing.

  14. #14
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    I have a funny feeling this is going to fade away......

  15. #15
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Yeah....I thought so.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •