Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Switchboard mouseover oddity

Discussion in 'Information Technology' started by default105, Jul 28, 2006.

  1. default105

    default105
    Expand Collapse
    Guest

    I am fairly new to coding functions so please bear with me. I wanted to add
    a mouse over effect to the switchboard. I have found this harder than I
    expected. I started this whole escapade with a form not linked to any
    table/query. I created a basic function and tested it on a label in the
    form. After some time I was able to get it to work with the label and the
    form by calling the function on the the label mousemove and detail mousemove
    event.

    So I tried to impliment the same with the switchboard. Now here is where
    things changed, when the mouse moves over the label, it changes the back
    color but when it moves to detail it doesn't change back to the previous
    color. To make a long story short, after some time messing with the code, I
    put it back to the original and tried this. I copied the items and code from
    the switchboard form to the MouseMove form but left the original labeil i
    created on the MouseMove form. The original label still works fine but if I
    try to add another label and add the code to the mouse move event it reacts
    the same as the original switchboard problem. So out of curiousity I did the
    same thing with another form with 2 labels and copied the switchboard info to
    it and the 2 labels worked fine but the anything else I added after the copy
    did not.

    I am at a loss, has any every heard of this before?

    Pete
     
  2. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    With odd and inconsistent errors like this, the first thing to do would be
    to ensure that the Name AutoCorrect boxes are unchecked under:
    Tools | Options | General
    Then compact the database:
    Tools | Database Utilities | Compact
    Explanation of why:
    http://allenbrowne.com/bug-03.html

    For what it's worth, the code below illustrates how to bold the text and
    change the foreground colour when a command button gets focus, or the mouse
    moves over it. Sounds somewhat similar to what you have been doing.

    Private lblMagic As Label
    Private Const conHighlightOff = 500
    Private Const conHighlightOn = 600
    Private Const conCmdForeColorNotSelected As Long = &H606060
    Private Const conCmdForeColorSelected As Long = 12941568

    Private Sub MagicLabelOn(lbl As Label)
    Dim bDoNothing As Boolean
    If Not lblMagic Is Nothing Then
    If lbl.Name = lblMagic.Name Then
    bDoNothing = True
    Else
    Call MagicLabelOff
    End If
    End If
    If Not bDoNothing Then
    lbl.FontWeight = conHighlightOn
    lbl.Parent.ForeColor = conCmdForeColorSelected
    Set lblMagic = lbl
    End If
    End Sub
    Private Sub MagicLabelOff()
    If Not lblMagic Is Nothing Then
    lblMagic.FontWeight = conHighlightOff
    lblMagic.Parent.ForeColor = conCmdForeColorNotSelected
    Set lblMagic = Nothing
    End If
    End Sub
    Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, _
    X As Single, Y As Single)
    Call MagicLabelOff
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
    Set lblMagic = Nothing
    End Sub

    'Example of what goes in the GotFocus and MouseMove of each command button:
    Private Sub cmdReport_GotFocus()
    Call MagicLabelOn(Me.lblcmdReport)
    End Sub
    Private Sub cmdReport_MouseMove(Button As Integer, Shift As Integer, _
    X As Single, Y As Single)
    Call MagicLabelOn(Me.lblcmdReport)
    End Sub

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "default105" <default105@discussions.microsoft.com> wrote in message
    news:61AC8C21-FF72-489A-8A28-725F34B52295@microsoft.com...
    >I am fairly new to coding functions so please bear with me. I wanted to
    >add
    > a mouse over effect to the switchboard. I have found this harder than I
    > expected. I started this whole escapade with a form not linked to any
    > table/query. I created a basic function and tested it on a label in the
    > form. After some time I was able to get it to work with the label and the
    > form by calling the function on the the label mousemove and detail
    > mousemove
    > event.
    >
    > So I tried to impliment the same with the switchboard. Now here is where
    > things changed, when the mouse moves over the label, it changes the back
    > color but when it moves to detail it doesn't change back to the previous
    > color. To make a long story short, after some time messing with the code,
    > I
    > put it back to the original and tried this. I copied the items and code
    > from
    > the switchboard form to the MouseMove form but left the original labeil i
    > created on the MouseMove form. The original label still works fine but if
    > I
    > try to add another label and add the code to the mouse move event it
    > reacts
    > the same as the original switchboard problem. So out of curiousity I did
    > the
    > same thing with another form with 2 labels and copied the switchboard info
    > to
    > it and the 2 labels worked fine but the anything else I added after the
    > copy
    > did not.
    >
    > I am at a loss, has any every heard of this before?
    >
    > Pete
     
  3. default105

    default105
    Expand Collapse
    Guest

    Well if this makes any sense, I copied a code in the programming group for
    ToggleCtrlColor and tested it in another form and it works but it will not
    work in the switchboard form. Strange is how this all goes back to something
    with the switchboard or the code with the switchboard that is taking control
    of the form.

    I did not get to try your example yet but I almost feel that my best option
    is going to be build my old switchboard from scratch.

    "Allen Browne" wrote:

    > With odd and inconsistent errors like this, the first thing to do would be
    > to ensure that the Name AutoCorrect boxes are unchecked under:
    > Tools | Options | General
    > Then compact the database:
    > Tools | Database Utilities | Compact
    > Explanation of why:
    > http://allenbrowne.com/bug-03.html
    >
    > For what it's worth, the code below illustrates how to bold the text and
    > change the foreground colour when a command button gets focus, or the mouse
    > moves over it. Sounds somewhat similar to what you have been doing.
    >
    > Private lblMagic As Label
    > Private Const conHighlightOff = 500
    > Private Const conHighlightOn = 600
    > Private Const conCmdForeColorNotSelected As Long = &H606060
    > Private Const conCmdForeColorSelected As Long = 12941568
    >
    > Private Sub MagicLabelOn(lbl As Label)
    > Dim bDoNothing As Boolean
    > If Not lblMagic Is Nothing Then
    > If lbl.Name = lblMagic.Name Then
    > bDoNothing = True
    > Else
    > Call MagicLabelOff
    > End If
    > End If
    > If Not bDoNothing Then
    > lbl.FontWeight = conHighlightOn
    > lbl.Parent.ForeColor = conCmdForeColorSelected
    > Set lblMagic = lbl
    > End If
    > End Sub
    > Private Sub MagicLabelOff()
    > If Not lblMagic Is Nothing Then
    > lblMagic.FontWeight = conHighlightOff
    > lblMagic.Parent.ForeColor = conCmdForeColorNotSelected
    > Set lblMagic = Nothing
    > End If
    > End Sub
    > Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, _
    > X As Single, Y As Single)
    > Call MagicLabelOff
    > End Sub
    > Private Sub Form_Unload(Cancel As Integer)
    > Set lblMagic = Nothing
    > End Sub
     
  4. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    Did you disable NameAutoCorrupt?

    A decompile would not hurt either. Make a copy of the database, and then
    enter something like this at the command prompt while Access is not running.
    It is all one line, and include the quotes:
    "c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
    "c:\MyPath\MyDatabase.mdb"
    Then compact again.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "default105" <default105@discussions.microsoft.com> wrote in message
    news:FC3D6926-B415-4B00-B795-0615C59C6A3D@microsoft.com...
    > Well if this makes any sense, I copied a code in the programming group for
    > ToggleCtrlColor and tested it in another form and it works but it will not
    > work in the switchboard form. Strange is how this all goes back to
    > something
    > with the switchboard or the code with the switchboard that is taking
    > control
    > of the form.
    >
    > I did not get to try your example yet but I almost feel that my best
    > option
    > is going to be build my old switchboard from scratch.
    >
    > "Allen Browne" wrote:
    >
    >> With odd and inconsistent errors like this, the first thing to do would
    >> be
    >> to ensure that the Name AutoCorrect boxes are unchecked under:
    >> Tools | Options | General
    >> Then compact the database:
    >> Tools | Database Utilities | Compact
    >> Explanation of why:
    >> http://allenbrowne.com/bug-03.html
    >>
    >> For what it's worth, the code below illustrates how to bold the text and
    >> change the foreground colour when a command button gets focus, or the
    >> mouse
    >> moves over it. Sounds somewhat similar to what you have been doing.
    >>
    >> Private lblMagic As Label
    >> Private Const conHighlightOff = 500
    >> Private Const conHighlightOn = 600
    >> Private Const conCmdForeColorNotSelected As Long = &H606060
    >> Private Const conCmdForeColorSelected As Long = 12941568
    >>
    >> Private Sub MagicLabelOn(lbl As Label)
    >> Dim bDoNothing As Boolean
    >> If Not lblMagic Is Nothing Then
    >> If lbl.Name = lblMagic.Name Then
    >> bDoNothing = True
    >> Else
    >> Call MagicLabelOff
    >> End If
    >> End If
    >> If Not bDoNothing Then
    >> lbl.FontWeight = conHighlightOn
    >> lbl.Parent.ForeColor = conCmdForeColorSelected
    >> Set lblMagic = lbl
    >> End If
    >> End Sub
    >> Private Sub MagicLabelOff()
    >> If Not lblMagic Is Nothing Then
    >> lblMagic.FontWeight = conHighlightOff
    >> lblMagic.Parent.ForeColor = conCmdForeColorNotSelected
    >> Set lblMagic = Nothing
    >> End If
    >> End Sub
    >> Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, _
    >> X As Single, Y As Single)
    >> Call MagicLabelOff
    >> End Sub
    >> Private Sub Form_Unload(Cancel As Integer)
    >> Set lblMagic = Nothing
    >> End Sub
     
  5. default105

    default105
    Expand Collapse
    Guest

    Yes Sir, I have done everything you have asked and have double checked my
    steps and tried again. Still acts the same and the form MouseMove with the
    original label mouseover effects are working but the ones associated with the
    items copied over from the switchboard dont, they highlight but dont release
    on detail_mousemove (but the original label will).

    I just wonder if it is not from the FillOptions code that is causing the
    issues.

    Maybe it doesn't recognise the detail after the build of the switchboard
    with those items. Well scratch that idea, I was using prior to this the
    HandleFocus() code that I found online which worked somewhat ok but I noticed
    that it had issues with a fast click of the mouse or if the mouse was moving
    while clicking. I just thought there had to be a better way and realized that
    using a simple function I didnt have the problem with the fast click/while
    moving.

    "Allen Browne" wrote:

    > Did you disable NameAutoCorrupt?
    >
    > A decompile would not hurt either. Make a copy of the database, and then
    > enter something like this at the command prompt while Access is not running.
    > It is all one line, and include the quotes:
    > "c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
    > "c:\MyPath\MyDatabase.mdb"
    > Then compact again.
    >
    > --
    > Allen Browne - Microsoft MVP. Perth, Western Australia.
    > Tips for Access users - http://allenbrowne.com/tips.html
    > Reply to group, rather than allenbrowne at mvps dot org.
     
  6. Jeff Conrad

    Jeff Conrad
    Expand Collapse
    Guest

    I have a working sample of bolding the labels on the Switchboard form here:

    http://home.bendbroadband.com/conradsystems/accessjunkie/switchboardfaq.html#bold

    See if that sample works for you.

    One thing to note that may be affecting your tests:
    A unattached label will generate a MouseMove event, but a label that is
    a child of another control will not.
    --
    Jeff Conrad
    Access Junkie - MVP
    http://home.bendbroadband.com/conradsystems/accessjunkie.html
    http://www.access.qbuilt.com/html/articles.html

    "default105" wrote in message:
    news:61AC8C21-FF72-489A-8A28-725F34B52295@microsoft.com...

    >I am fairly new to coding functions so please bear with me. I wanted to add
    > a mouse over effect to the switchboard. I have found this harder than I
    > expected. I started this whole escapade with a form not linked to any
    > table/query. I created a basic function and tested it on a label in the
    > form. After some time I was able to get it to work with the label and the
    > form by calling the function on the the label mousemove and detail mousemove
    > event.
    >
    > So I tried to impliment the same with the switchboard. Now here is where
    > things changed, when the mouse moves over the label, it changes the back
    > color but when it moves to detail it doesn't change back to the previous
    > color. To make a long story short, after some time messing with the code, I
    > put it back to the original and tried this. I copied the items and code from
    > the switchboard form to the MouseMove form but left the original labeil i
    > created on the MouseMove form. The original label still works fine but if I
    > try to add another label and add the code to the mouse move event it reacts
    > the same as the original switchboard problem. So out of curiousity I did the
    > same thing with another form with 2 labels and copied the switchboard info to
    > it and the 2 labels worked fine but the anything else I added after the copy
    > did not.
    >
    > I am at a loss, has any every heard of this before?
     
  7. default105

    default105
    Expand Collapse
    Guest

    Well, after reviewing what you have I see how yours is much better than what
    I had. I don't quite understand why the code I wrote worked on one form but
    not the switchboard but yours works perfectly.

    Maybe you could answer this for me, a lot of the mousemove code I have seen
    will cause the property window to flicker rapidly, but as with yours and a
    few others I have looked at, it will only flicker once when moving on or off
    the control. I know that is a very vague question but I was hoping with your
    experience that you might know what I am speaking of.

    This has to be one of the most painful ways to learn something (bruteforce
    method). But I do love it. A big 'Thanks', to all of you guys and gals and
    especially for helping blockheaded people like me.

    "Allen Browne" wrote:
     
  8. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    The trick to getting it flicker-free is to only change the properties when
    they need changing--not every time the MouseMove event occurs.

    The code does that by declaring a module-level variable, lblMagic, and
    setting it to the one that currently has focus. This variable survives
    between events. The code test if the event that triggered the MouseMove is
    the same label, and if so, sets the bDoNothing flag to avoid the flicker.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "default105" <default105@discussions.microsoft.com> wrote in message
    news:A6DB8F58-3F0A-4483-A10E-46AB59110A49@microsoft.com...
    > Well, after reviewing what you have I see how yours is much better than
    > what
    > I had. I don't quite understand why the code I wrote worked on one form
    > but
    > not the switchboard but yours works perfectly.
    >
    > Maybe you could answer this for me, a lot of the mousemove code I have
    > seen
    > will cause the property window to flicker rapidly, but as with yours and a
    > few others I have looked at, it will only flicker once when moving on or
    > off
    > the control. I know that is a very vague question but I was hoping with
    > your
    > experience that you might know what I am speaking of.
    >
    > This has to be one of the most painful ways to learn something (bruteforce
    > method). But I do love it. A big 'Thanks', to all of you guys and gals
    > and
    > especially for helping blockheaded people like me.
    >
    > "Allen Browne" wrote:
    >
     

Share This Page