Results 1 to 8 of 8
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combobox opens - I don't want it to ! (WIN 2000 Acc 97)

    Here is the code:

    Private Sub cboVerified_by_GotFocus()
    If Not IsNull([cboVerified_by]) Then
    [cboVerified_by].Locked = True
    MsgBox "THIS RECORD HAS ALREADY BEEN VERIFIED", vbExclamation, "DATA ENTRY ERROR"
    Exit Sub
    Else
    [cboVerified_by].Locked = False

    End If

    End Sub

    The above code works just fine. My question is:
    When the user clicks OK on the msgbox, the combobox still drops down. Is there a way to prevent this?

    Thanks as always,

    Michael

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Combobox opens - I don't want it to ! (WIN 2000 Acc 97)

    I would use combo On Enter event rather than Got Focus, and use form On Current event to lock/unlock combo box. To prevent combo box from dropping down after msgbox displayed need to move focus elsewhere on form. Form On Current event:

    <pre>Private Sub Form_Current()
    With Me
    .ComboVerified.Locked = Not IsNull(.Verified)
    End With
    End Sub
    </pre>

    In above example name of field is "Verified", name of combo is "ComboVerified". If combo unbound (not sure in your case) replace Not IsNull(.Verified) with Not IsNull(.ComboVerified). Combo box On Enter event:
    <pre>Private Sub ComboVerified_Enter()
    If Me.ComboVerified.Locked = True Then
    MsgBox "Record has been verified.", vbExclamation, "ERROR"
    Me.TextBox1.SetFocus
    End If
    End Sub
    </pre>

    In above sample replace "TextBox1" with another control on form where it'd be logical to move focus to, either next control after combo or first control on form.

    HTH

    PS: Why have combo if you can't change value? What if someone makes mistake, then its locked and you can't enter correction.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Combobox opens - I don't want it to ! (WIN 2000 Acc 97)

    Do you have code somewhere else that tells the combobox to dropdown?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combobox opens - I don't want it to ! (WIN 2000 Acc 97)

    Why have combo if you can't change value? What if someone makes mistake, then its locked and you can't enter correction.

    The combobox lists all users in my dept. After they verify a record, they click the combobox-find their name. They are audited on how many they verify. Believe it or not, we have had folks go in after the fact, and change the name to theirs so their stats would increase. So the boss said to lock it once a name is entered. If the original person makes a mistake, they notify me and I change it behind the scenes.

    I have used your suggestion of moving the focus elsewhere and it works fine.

    Thanks for your help Mark D !!

    Michael

    Mark L:
    Do you have code somewhere else that tells the combobox to dropdown?

    The above code is the only code referencing this combobox.

  5. #5
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Combobox opens - I don't want it to ! (WIN 2000 Acc 97)

    <hr>So the boss said to lock it once a name is entered<hr>
    If the Boss said so I guess that's a good reason!

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Combobox opens - I don't want it to ! (WIN 2000 Acc 97)

    Why not get the NT user who signed on and record that behind the scenes.
    HTH
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  7. #7
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combobox opens - I don't want it to ! (WIN 2000 Acc 97)

    "Why not get the NT user who signed on and record that behind the scenes

    Pat - I know that - you know that. We programmers can/should do this.
    But the boss would rather not allow it to happen in the first place,
    than to have to keep track of the cheaters.

    (See MarkD's post above)
    <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

    Thanks for replying Pat!!

    Michael

  8. #8
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Combobox opens - I don't want it to ! (WIN 2000 Acc 97)

    Do you security on the database?

    If so, you could use the currentuser function to put in who did the verifying automatically when they do it, without needing the combo box.
    Regards
    John



Posting Permissions

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