Cascading Combo Boxes w/ SQL in a PRoject

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
 
K

kingston via AccessMonster.com

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
 
P

pltaylor3

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
 
K

kingston via AccessMonster.com

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top