PDA

View Full Version : Lookup in form to fill out various categories



dirtychinch
06-12-2014, 03:55 AM
Morning all,

The answer is probably staring me right in the face, but I'm trying to create a form whereby if you select a unique number in a combobox (lookup from a query), then other boxes on the same form could look up the associated values from the query.

Ie. I select code 45678913, and another boxes produces the name, say "Headquarters"...

I have no idea how to do this and feel pretty stupid tbh!!

Jonathon

jonh
06-12-2014, 04:16 AM
Get data from the second column of the combo?

control source of textbox or whatever...
=Combo0.column(1)

coded example for combo



Private Sub Form_Open(Cancel As Integer)
With Combo0
.ColumnCount = 2
.ColumnWidths = "2 cm"
.RowSourceType = "value list"
.RowSource = "12345;name1;67890;name2"
End With
End Sub

dirtychinch
06-12-2014, 05:37 AM
Hi jonh,

Thanks for your response.

No, I don't need the info for the second column. I simply can't get other boxes in the form to look up values in their table based on this unique code...feeling stupid here, hah!

jonh
06-12-2014, 06:15 AM
Oh. Create a subform and bind it to the combo using link master and link child fields, or set the subforms recordsource on the onclick event of the combo? Or use DLookup?

dirtychinch
06-12-2014, 07:33 AM
Thanks again. I think you may be overcomplicating it. What I'm trying to achieve, in Excel terms, is a vlookup based on the combobox. But I thought that Access did this easily, and it seems rather complicated to me. I'll research the dlookup and the other bits though, thanks.