Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box populates text boxes on a form 1

Status
Not open for further replies.

hlkelly

Technical User
Jul 11, 2003
108
US
I have a simple form with a combo box. I want the selection in the combo box to automatically populate the remaining text fields with that record's data.

Thanks.

Heather
 
So, the combo box is a search box then? Open the properties on the combo box, select the Events tab, select [Event Procedure] after After Update. Next, click the ... next to where you just added [Event Procedure], and drop in the following code where Combo10 is the name of your combo box and searchFieldName is the name of the field to search on:

Code:
Private Sub Combo10_AfterUpdate()
    Dim rs As Object

    Set rs = Me.Recordset.Clone

    rs.FindFirst "[searchFieldName] = " & Str(Nz(Me![Combo10], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
 
Let me know if the above code is what you're looking for, or if you're seeking more along the lines of choose an option on the drop down, and it auto-fills fields in on the form.
 
I don't think that code is what I'm looking for. I want to choose an option in the drop down and the fields in the form auto-fill. Thanks so much!
 
okay, I'll put something together then. Can you give me the names of the fields you want to autofill? Or I can use temp names and you can convert it over.

Also, is the auto-fill data based on information in another table?
 
The auto-fill data is based on the same table that the combo box is pulling from.

Basically, I want to be able to pull a last name from the combo box and have it show that records first name, NETID, Completed, Incomplete, Notes fields so the latter three can be updated. I'll lock the first name and NETID so they can't be changed.

Thanks so much.

 
The auto-fill data is from a different table than the form is based on however, correct?
 
No, actually, it's based on the same table.
 
You have a couple of options:

DLookup is one way to find data based on your combo.

The other way is to have your combi query retrieve all of the fields that you want to use - eg

RefID, Name, Address, City, State, Zip

Then set the Address, City, State & Zip as follows;

me.address = me.combo.column(2)
Me.city = me.combo.column(3)
Etc

Your combo column widths would be as follows
0;1;0;0;0



I haven't failed, I have just found 10,000 ways that it won't work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top