Automatic drop-down selection?

  • Thread starter evilcowstare via AccessMonster.com
  • Start date
E

evilcowstare via AccessMonster.com

Hi Everyone, maybe you can help me out on something...

I have a table on contacts that also have a form to go with it, to add new
ones or look over the old ones.
I have another seperate form which I would like to link to the contact but
dont know how to do it.

What I want to do is to have a button on the contact form that once I click
will automatically select the name on the next form for me, so for example....


I add a new contact - name address etc I click the button, the next form will
open and the name I just added will be automatically selected in the drop-
down box I have on the next form.

So I guess I just want the drop-down to pick up on the name from the other
form and select it automatically.

Can anyone help?

Thank You and Happy Easter!
 
L

Larry Linson

If the form from which you want to select is a continuous form, that is,
showing multiple records, I'd suggest you use the Click or Double-Click
event. In that event code, you'll use the DoCmd.OpenForm statement, with a
WHERE condition. As a start, in a module window, put the cursor in the
DoCmd.OpenForm statement and read the Help.

The following (air) code might be a start, assuming the contact Records have
a key of Contact ID that is a Long Integer (could be AutoNumber), and that
ContactID is displayed in a TextBox called txtID, and that the next form is
called frmNext:

Dim strWhere as String

strWhere = "ContactID = " & Me.txtID
DoCmd.OpenForm "frmNext",,,strWhere

If your ContactID is text, the line setting the strWhere would read:

strWhere = "ContactID = """ & Me.txtID & """"

Yes, the multiple double-quotes are necessary, if that is a Text Field.

I'm not at all certain what you have in mind regarding your comment
"drop-down to pick up on the name". The above code would open the frmNext to
the proper Record without any drop-down (Combo Box) control.

Larry Linson
Microsoft Access MVP
 
Top