Link to home
Start Free TrialLog in
Avatar of Michael Noze
Michael Noze

asked on

Access Form Dlookup - Using a Combo box for the expression value

Hi Experts,

I'm trying to populate a text box with a Dlookup based on a combobox value.
Informations:
Form containing the combobox: frmInspection
combobox: cboEquipment
table: tblEquipment
Unique ID in the table: [EquipementID]
Field wanted in the textbox: [HS]

This is the code I've tried but didn't work:

Set rst2 = CurrentDb.OpenRecordset("tblEquipment")
With rst
            Forms("frmInspection").Form.Controls("txtHS") = _
            DLookup(.Fields("HS"), "tblEquipment", Forms("frmInspection").Form.cboEquipement = _
            .Fields("HS"))
Wend
End With

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Michael Noze
Michael Noze

ASKER

Thanks! It worked perfectly!