Cascading Combo Boxes w/ SQL in a PRoject

  • Thread starter Thread starter pltaylor3
  • Start date Start date
P

pltaylor3

For some reason I cannot get this code to create my cascading combo
box.

SELECT EngineNumber FROM dbo.Engine
Where(((Program)=[forms]![Selection]![prgrm]))

This is pulling information from a SQL database that the form is linked
to and it gives me the error "Incorrect Syntax near '!'" the names of
the access value are correct and the query works when i stick a value
for prgrm in place of the "[forms]![Selection]![prgrm]"
any help would be greatly appreciated.
thanks
 
Try this:

SELECT EngineNumber FROM dbo.Engine
Where(((Program)='" & [forms]![Selection]![prgrm] & "'"))

For some reason I cannot get this code to create my cascading combo
box.

SELECT EngineNumber FROM dbo.Engine
Where(((Program)=[forms]![Selection]![prgrm]))

This is pulling information from a SQL database that the form is linked
to and it gives me the error "Incorrect Syntax near '!'" the names of
the access value are correct and the query works when i stick a value
for prgrm in place of the "[forms]![Selection]![prgrm]"
any help would be greatly appreciated.
thanks
 
That leads to an empty combo box. I am open to suggestions. I believe
it is passing the value & [forms]![Selection]![prgrm] & instead of what
that value should represent (i.e. the value in the text box prgrm).



Try this:

SELECT EngineNumber FROM dbo.Engine
Where(((Program)='" & [forms]![Selection]![prgrm] & "'"))

For some reason I cannot get this code to create my cascading combo
box.

SELECT EngineNumber FROM dbo.Engine
Where(((Program)=[forms]![Selection]![prgrm]))

This is pulling information from a SQL database that the form is linked
to and it gives me the error "Incorrect Syntax near '!'" the names of
the access value are correct and the query works when i stick a value
for prgrm in place of the "[forms]![Selection]![prgrm]"
any help would be greatly appreciated.
thanks
 
Verify that [forms]![Selection]![prgrm] returns the value in the control.
Enter something in the control (remember to press the Enter key after putting
in a value). Then open the form where the combo box resides. If the two are
in the same form, requery the combo box after the input control is updated:

DoCmd Me.ComboBox.Requery

If [forms]![Selection]![prgrm] doesn't return anything, check the name of the
form and the control. You can also verify this by entering something in the
control, then typing Crtl+g. In the results pane (bottom) of the programming
window, type ?[forms]![Selection]![prgrm]. It should return what is in the
control.

The query I supplied assumes that the field [Program] is a text field. If it
is a numerical field, remove the single quotes in the expression. Also, this
might be failing if you are working with subforms. If the input control is
in a subform, it needs to be referenced differently.

That leads to an empty combo box. I am open to suggestions. I believe
it is passing the value & [forms]![Selection]![prgrm] & instead of what
that value should represent (i.e. the value in the text box prgrm).
Try this:
[quoted text clipped - 17 lines]
Message posted via AccessMonster.com
 
Back
Top