Capture when user leaves an Access combobox selection

  • Thread starter Brady Mann - Amatuer Extraordinaire
  • Start date
B

Brady Mann - Amatuer Extraordinaire

Hi all,

I'm new to the newsgroup and Access programming but, I'm learning
MUCH from you folks. Here is my situation.
I have a form (Access 2K)that I have protected from user entries via
Me.AllowEdits, Me.AllowAdditions, and Me.AllowDeletions = False. I also
have a combobox used to select the record the user would like to go to
(along with the usual button for "next" and "previous" record).
Here is the issue.
As you know, navigating with the combobox while Me.AllowEdits=False
is not possible. So, on the "Got Focus" event of the control I set
Me.AllowEdits = True. After this I use the "AfterUpdate" event to move
to the selected record (Me.Allow* is set back to False when the
Form_AfterUpdate event fires).
The trouble is, if the user clicks on the combobox and then clicks
somewhere else on the form, they are free to edit the record as
Me.AllowEdit = True at this point.
So here is my question: What can I do to programmatically recognize
that the user has just "abandoned" the navigation combobox? I need an
event of some kind to put in the "Me.AllowEdits=False" coding.

***code starts here
Private Sub cbo_SelectRecord_GotFocus()
Me.AllowEdits = True

End Sub

Private Sub cbo_SelectRecord_AfterUpdate()
On Error GoTo Exit_cbo_SelectRecord_AfterUpdate

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone

rs.Findfirst "[OppID] = " & Str(Me![cbo_SelectRecord])
Me.Bookmark = rs.Bookmark

Exit_cbo_SelectRecord_AfterUpdate:
Me.AllowEdits = False
Exit Sub

Err_cbo_SelectRecord_AfterUpdate:
msgbox Err.Description
Resume Exit_cbo_SelectRecord_AfterUpdate

End Sub
***code ends here
 
B

Brady Mann - Amatuer Extraordinaire

Dear Ken Snell (Super Tremendous Dude Extraordinaire),

That's it! The Exit event was exactly what I was looking for and
works perfectly. Many MANY thanks for the advice and quick reply. Take
care.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top