combo default to most recent entry

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that contains a combo box with a list of names. I am recording
multiple records for each name. I would like to enter data for a name, and
since I am immediately entering a new record for the same name, have the
combo box default to the name in the record I just entered. Then, when I
switch to a new name, have it stick with that new name, and so on. How do I
do this? I'm pretty new to Access and code, so please be gentle! Thanks!
 
Coqui-
since you're new to this, I'm going to show you a great resource for finding
out stuff. If you search on google groups for the keywords "access set
combobox default", you will see several discussions on this topic. This is a
great way to find info, because you can find it immediatly, rather than
waiting for someone to respond, and because you can usually see lots of
different ideas on the topic, so you may get a more in depth answer. It's
best to try that first and then post to the newsgroup if you're still
stumped.
hope this helps
-John
 
I have a form that contains a combo box with a list of names. I am recording
multiple records for each name. I would like to enter data for a name, and
since I am immediately entering a new record for the same name, have the
combo box default to the name in the record I just entered. Then, when I
switch to a new name, have it stick with that new name, and so on. How do I
do this? I'm pretty new to Access and code, so please be gentle! Thanks!

It's pretty easy. Let's say your combo box is named cboName. Open the
form in design view; view its Properties; select the combo box, and
find the AfterUpdate event on the Events tab. Click the ... icon by
that event, and choose Code Builder. Access will give you the Sub and
End Sub lines; you just need to add one line between them:

Private Sub cboName_AfterUpdate()
Me!cboName.DefaultValue = """" & Me!cboName & """"
End Sub

The multiple quotes are just to enter literal quotemarks into the
DefaultValue property, so if you enter a name O'Niell the default
value property becomes

"O'Niell"

John W. Vinson[MVP]
 
Back
Top