Results 1 to 13 of 13
  1. #1
    Lounger
    Join Date
    Jul 2002
    Location
    Wellington, New Zealand
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dblclick event (vba on word 2k)

    how do I pass the Cancel to this event.

    In the app I am working on it would be much easier to duplicate a user double click than to repeat all the code seperately, when I try to fire the event I get a type mismatch error regardless of the value I try to pass.

    Thanking you in advance

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: dblclick event (vba on word 2k)

    You might create a separate procedure or function and call that from the double-click event instead of the other way round.

  3. #3
    Lounger
    Join Date
    Jul 2002
    Location
    Wellington, New Zealand
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dblclick event (vba on word 2k)

    Cheers Hans
    Maybe a bit more info will explain

    Through out this development I have to respond to exact use input eg key strokes.
    I have found that the ActiveControl etc does not return accurate information when the control is contained in an mpg/ frame etc. I am also using text boxes as lables in the navigation area so I can use activecontrol
    I spent ages trying to get this to work in an tidy way but in the end settled for a way that worked.
    The query involves updating the lable with the values entered in text fields. This is working but... Depending on the value of an option group different mpg's are displayed but there is only ever one navigation map so the lables are dependent on which mpg is displayed. THe easiest way I can think of to change the lable color etc when the user changes her option group selection is to try to fire the dblclick event. rather than duplicate all the navigation code. If I knew what to pass to the Cancel this would work I think.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: dblclick event (vba on word 2k)

    Do you actually need the Cancel argument (in the sense that you want to set it to True under certain circumstances), or is it just that the DoubleClick event won't work unless you pass it something as Cancel argument?

  5. #5
    Lounger
    Join Date
    Jul 2002
    Location
    Wellington, New Zealand
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dblclick event (vba on word 2k)

    It seems to want an arguement passed.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: dblclick event (vba on word 2k)

    In that case, I repeat my previous suggestion. Here it is in a little bit more detail:

    1. Create a new procedure that contains the code you want to execute on a double click:

    Private Sub DoubleClickAction()
    ' Your code goes here
    ...
    End sub

    2. Call this procedure in the double click event:

    Private Sub ..._DblClick(Cancel As MSForms.ReturnBoolean)
    DoubleClickAction
    End Sub

    3. Also call this procdure (DoubleClickAction) where you need it to simulate the double click.

    If this doesn't help, feel free to post back, but please explain why you can't use this.

  7. #7
    Lounger
    Join Date
    Jul 2002
    Location
    Wellington, New Zealand
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dblclick event (vba on word 2k)

    Hans
    Hopefully this explains why I am all tied up.

    I currently call to Sub mpgNavigation(referForm As UserForm, Optional referID As String) with something like Call Navigation.mpgNavigation(Me) or just Call Navigation.mpgNavigation(Me, "Team") from the dblclick event of multiple lables.
    in the first instance there is only one mpg on the form so the map always will refer to it.( lables named like tal2_ClientDetails_Nav1.... (tal is for text as lable))
    in the second instance there are more than one mpg and the map must refer to the one that is not hidden (lables named tal3_MPGs_Nav1... MPGS indicates refers to multiple mpgs)
    The string is because on one form there are multiple mpg's and my naming convention is like mpg3_TeamDetails where the first 3 letters are the control type and the 4th letter is the form it is on. I interogate the activecontrol.name to decide which mpg is visible and use a case statement to determin the actions taken ( recolouring and changing the caption) plus move through the pages.
    I use the following code to give me a string for the case statement
    f referID = "" Then
    strMPGName = Mid(referForm.ActiveControl.Name, 6, 4)
    Else
    strMPGName = referID
    End If
    I use referform.activecontrol 4 times in the proc eg.
    If Right(referForm.ActiveControl.Name, 1) - 1 = referForm.mpg3_TeamDetails.Value Then Exit Sub ' no need to take action if already on the page clicked

    So
    By firing the dblclick event I get access to the activecontrol property

    Hope this makes it a bit clearer
    Thanks for the time you have put in so far

    I use .name and .backcolour only so I could pass the activecontrol.name to this proc then all I would need to do is workout how to access the controls backcolor based on this string
    Is that a better way to do it??

    Having to leave now so looking forward to your comments tommorrow

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dblclick event (vba on word 2k)

    Please clarify.

    The double click event includes a Cancel argument.

    You set Canel to either True or False as needed.

  9. #9
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dblclick event (vba on word 2k)

    You should not be calling the double click event in your code.
    In any case, Cancel is an OUTPUT, not an INPUT argument.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: dblclick event (vba on word 2k)

    Hi Doj,

    I'm afraid I don't understand at all, but perhaps you can use something like the following:

    Private Sub FireDoubleClick()
    Dim rbCancel As MSForms.ReturnBoolean
    Call Label1_DblClick(rbCancel)
    End Sub

    where Label1 should be replaced by the name of of the label whose double click event you want to fire.

    Perhaps you could pass the label as a control to the mpgNavigation procedure. Here is a very simple example:

    Sub mpgNavigation(ctl As MSForms.Control)
    If ctl.BackColor = vbRed Then
    ctl.BackColor = vbYellow
    Else
    ctl.BackColor = vbRed
    End If
    End Sub

    You would call it like this:

    Private Sub Label1_DblClick(Cancel As MSForms.ReturnBoolean)
    Call mpgNavigation(Label1)
    End Sub

    You can use the Parent property of the control to find out where it is located. Parent returns an object representing the userform, frame of page that contains the control. So ctl.Parent.Name will tell you the name of the object containing the control etc.

  11. #11
    Lounger
    Join Date
    Jul 2002
    Location
    Wellington, New Zealand
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dblclick event (vba on word 2k)

    Hans and Howard

    I was thinking about this last night after I left

    The basic problem was ensuring that the focus was on the correct control b4 I called my navigation function so
    I set the focus to that control and called the navigation function from the option buttons click event

    Once I worked around the error trapping in the navigation function it worked fine

    the final code looked like
    tal3_MPGs_Nav1.SetFocus
    Call Navigation.mpgNavigation(Me, "OBUR")
    chk3_OBUR1_Include.SetFocus

    SImple eh...I tend to complicate matters in looking for the simpliest solution

    Thanks for all your help and the time you have put in

    Howard re your Post Post: 248684
    "You should not be calling the double click event in your code.
    In any case, Cancel is an OUTPUT, not an INPUT argument."

    Where can I go to learn more about this

  12. #12
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dblclick event (vba on word 2k)

    Each event is described in the Help in the VBIDE.

    To learn about programming userforms, the best sources are VB 6 books.
    VB 6 Forms are a bit different than VBA Userforms, but the fundamentals are the same.

    You should be able to write your code so that it matters not which control has the focus, you can always SetFocus as needed.

    The idea of event oriented programming is events do not usually occur in a predictable sequence, so each event code has to handle events, mostly, independent of other events.

    One uses events such as BeforeUpdate to enforce correct use of a particular control, then the code for one, or more, command button events usually does the actual processing that produces a final result. How you do this is specific to each app.

  13. #13
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: dblclick event (vba on word 2k)

    Howard,
    <hr>The idea of event oriented programming is events do not usually occur in a predictable sequence, so each event code has to handle events, mostly, independent of other events.
    <hr>
    Depending on what you're doing (and, to some extent, what app you're working in), this could be misleading. A part of the battle (at least in an app like Access) is being aware of in what order form events are triggered so as to determine which event will best handle what you are trying to achieve.
    Just a small clarification, FWIW.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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