Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form as parameter in a SQL query

Status
Not open for further replies.

pasqwal

Programmer
Apr 18, 2002
9
FR
I have a form in an Access project connected to a sql server database

I have a form with two comboBox
the first list give me a result from a table
the second give a result whitch depend of the first result
if it's not clear I'll give you an example

Table1 : one column with these values : a,b,c
table2 : two columns : one is the foreign key of table1, one is a value : so I have a-1, b-2, b-4, c-3

so if the value of the first list in my form is b, the second list contain 2 and 4.

how can I do to tell in a query that the value in the first list is a parameter for the second ?
sql server don't understand when the parameter is a value from a list
 
In the recordsource of the combo box, edit the SQL statement to have a WHERE clause of the combo boxes name.

Example:
WHERE MyField = Forms!MyForm!MyComboBox.Value

Change MyField to the name of your queries field to filter.
Change MyForm to the name of the form with the combo box.
Change MyComboBox to the name of the combo box.

God Bless,
Mike

Yes, I believe in Jesus. ;-)
"Neither is there salvation in any other: for there is none other name under heaven given among men, whereby we must be saved." (Acts 4:12, KJV)
 
here is my query

SELECT champ2 FROM Table2 WHERE champ1 = Forms!form1!champ1.Value

but it is an incorrect query

 
Try changing the name of the combo box. Access might think you are pointing to a field in the underlying query of the form, instead of a combo box. God Bless,
Mike

Yes, I believe in Jesus. ;-)
"Neither is there salvation in any other: for there is none other name under heaven given among men, whereby we must be saved." (Acts 4:12, KJV)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top