get values from selected item in a combo box

C

chris

Try this...

in the click event of the combobox put

if mycbo.listindex < 0 then exit sub
txtTerritory = dlookup
("[TerritoryField]","[AgentTable]","[AgentName] = '" &
mycbo.column(mycbo.listindex) & "'")

and similar for the agent id

-----Original Message-----
I have three related fields in a form along with other
fields, say, Agent ID, Agent Name and Territory(those
three fields constitute a table, tblAgent, where AgentID
is primary Key) along With Customer Name, Customer Phone
Number etc.
To make data entry easy, I want to choose agent Name from
a combo box, then Agent ID and Territory of that agent
automatically go to corresponding fields.
I find it is easy to do if the form has only those three fields.

Sub cboAgentName_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[strAgentName] = '" & Me! [cboAgentName] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

However, since my form is based on Customer Purchasing
records, I have other fields like Customer Name, Phone
#etc.
The above code doesn't work anymore. I guess I need to
open a recordset, tblAgent. But I don't know if it is
right or not. And how can I achieve this goal?
 

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