Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    'Before Update' and 'After Update' commands (2000)

    Hello,

    I am trying to use the "Before Update" and "After Update" commands to change the color of the drop down.
    Altough what l am trying to achieve is not quite working.

    When l click on the drop down l would like it to change to white then when the user clicks on another field it changes back to its default colour.
    What is happening is that the drop down is remaining white all the time even when the user clicks on the another cell when they have finished using the dropdown.
    Any assistance would be appreciated.


    Private Sub Combo137_BeforeUpdate(Cancel As Integer)
    Combo137.BackColor = 13819101
    End Sub


    Private Sub Combo137_AfterUpdate()
    Combo137.BackColor = 16777215
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[CDRL Ref] = '" & Me![Combo137] & "'"
    Me.Bookmark = rs.Bookmark
    End Sub

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

    Re: 'Before Update' and 'After Update' commands (2000)

    The Before Update and After Update events occur when the user changes something in a control. You want something to happen when the user enters or exits the control; you need the On Enter and On Exit events for that. Remove the code to set the background colour from the Before Update and After Update events, and add these procedures:

    Private Sub Combo137_Enter()
    Me.Combo137.BackColor = 13819101
    End Sub

    Private Sub Combo137_Exit(Cancel As Integer)
    Me.Combo137.BackColor = vbWhite
    End Sub

    (16777215 is white; VBA has the symbolic constant vbWhite for this)

    Note: it would be a good idea to give your controls meaningful names. "Combo137" is meaningless, it doesn't give a clue to what it does. Something like "cboFindRef" is much clearer.

  3. #3
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Before Update' and 'After Update' commands (2000)

    Thats works fine.
    I have made note of this for future reference.

    Thanks once again for your help Hans.

    Justin.

Posting Permissions

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