Consulting

Results 1 to 7 of 7

Thread: Command Button click

  1. #1
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location

    Command Button click

    Hello Again, I have a Form with 3 Command Buttons (this form will be use as a message box). In a module, I want to say that if i click choice 1, do the following. Choice 2, do this.... How do this "code the Click"....

    here is the example code

    [VBA]
    Sub Executive_Update()
    Dim Answer As String
    Dim MyNote As String


    MyNote = "Do you want to update the Executive File? (Warning: Only authorized personnel)"
    Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "???")
    If Answer = vbNo Then
    'Code for No button Press
    Exit Sub
    Else
    UserForm2.Show
    If UserForm2.cmddaily_Click Then
    UserForm2.Unload
    MsgBox (Daily)
    End If
    If UserForm2.cmdweekly = True Then
    UserForm2.Unload
    MsgBox (weekly)
    End If
    If UserForm2.cmdcancel = True Then
    Exit Sub
    End If


    MsgBox ("Complete")
    End If

    End Sub
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Is the code that you show accurate, does it really show that you will open form, hide it in the form code, and then carry on. Assuming so, set a module public variable for each butoon in the form and test that.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location
    I don't get it....

    Maybe it's not accurate, I can get the userform 2 to show, but in the module, I want those buttons on form2 to perform a particular task.

    in the module, i want the Daily to first, exit form2 and perform some task, how to I say that in the module, because it's not take userform2.cmdexit_click = true?

    I guess my question is how do it command a Click?

    I don't even know what I'm saying anymore.


    thanks for you help XLD

  4. #4
    VBAX Tutor nst1107's Avatar
    Joined
    Nov 2008
    Location
    Monticello
    Posts
    245
    Location
    Sounds like what you need to do is cut all the code you have in the If statment after "UserForm2.Show" and paste it in the respective _Click() events for each button of the userform.

  5. #5
    VBAX Tutor nst1107's Avatar
    Joined
    Nov 2008
    Location
    Monticello
    Posts
    245
    Location
    For instance, you might paste this into the declarations area of UserForm2:
    [VBA]
    Private Sub cmddaily_Click()
    Unload UserForm2
    MsgBox (Daily)
    End Sub
    Private Sub cmdweekly_Click()
    Unload UserForm2
    MsgBox (weekly)
    End Sub
    Private Sub cmdcancel_Click()
    Unload UserForm2
    End Sub
    [/VBA]

  6. #6
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location
    so i can only do the _Lick() within the form only????

  7. #7
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location
    thank you, worked!

Posting Permissions

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