Query based on value of combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to run a query where the "Where Clause" compares a field value and a combo box value. I can't get it to work, apparently I can't query based on the value property of a combo box, Thanks in advance

SELECT [Device].[Device_Model]
FROM Device
WHERE [Device].[Device_SN]=cboSerialNumber.Value;
 
Dear Brad:

The way to reference a combo box (or other control) is to use the
following syntax:

SELECT [Device].[Device_Model]
FROM Device
WHERE [Device].[Device_SN] = [Forms]![YourFormName]![cboSerialNumber]

You must replace YourFormName above with the exact name of the form on
which the control resides. Since the same named control can exist on
multiple forms, specifying the form name is an essential part of the
syntax.

Also, the form MUST be open when the query runs.

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 
Back
Top