autopopulating text boxes from combo boxes

148 views Asked by At

I have created a form to input new work orders in access. I want the text boxes in my form to populate from the selection in the combo box.

The combo box lists serial number for equipment, and once a serial number is selected, I want CompanyName, PurchDate, LastMaintenanceDate, & ModelNo to populate.

I saw an example of dlookup and tried this expression on the Company Name textbox:

=DLookUp("[CompanyName]","SerialNoInfo","[SerialNoInfo].SerialNo= " & Str([Combo341].[Text]))

I keep getting an error #Type or #Error in the box depending on what I do. When I try to build a code for the event on update, nothing happens at all. I have no idea what I am doing wrong.

1

There are 1 answers

0
Vedat Galimidi On

You can alternatively use :

Private Sub COMBOBOX_Change()

me.TEXTBOXNAME.Text = me.COMBOBOX.Column(X)

End Sub

Where TEXTBOXNAME is the the textbox you want to fill Where COMBOBOXis the the combobox from which you want to get data and X is the number of column with data (starting from 0 )