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!

Problem with using ComboBox using Query based on other ComboBox 1

Status
Not open for further replies.

bn2335813

Programmer
Oct 8, 2001
10
IL
Hi !
----

I have a subform which have four controls two of them are ComboBoxes.
the first ComboBox is based on a table TblModel and after choosing a Model and moving to the second ComboBox, the second ComboBox is based on a Query (made with QBE) which uses the first ComboBox as the criteria for selection.
The problem is that whenever I open the second ComboBox
a window is opened asking for parameter. It apears that the Query can't access the value from the first ComboBox !!.

Please Help !

Thanks !!!

 
By it asking for a parameter value, I would assume that the first combobox is not properly referenced in the query. It should be in the form of [FormName]![SubformName]![cboName]

What you can try is populating the first combobox with a value, & then running the query. If it returns a value successfully then you know that the query is working..... James Goodman
j.goodman00@btinternet.com
 
I checked everything but it still won't work !!
 
On the BeforeUpdate event for combo1, try:
Code:
Combo2.Requery


HTH

John
 
I have the same problem.

The issue is that the query is being executed in the SQL Server and it does not know about the value of the First combobox that is in access. So the SQL Server is asking for the parameter which it connot recognize.

I found a question similar to this and some suggestions as to how to solve it. One that has worked for me is to define the rowsource of the second combobox to a Value List. Build a query and populate the combobox.

Part of the code is here.

str_RowSource = ""
If Not rs.EOF Then
Do While Not rs.EOF
If i > 0 Then
str_RowSource = str_RowSource & ";"
End If
str_RowSource = str_RowSource & rs("Unit No")
i = i + 1
rs.MoveNext
Loop
End If

Me.UnitNo.RowSource = str_RowSource

Now I have the problem that this solution don't work if the str_RowSource is too big, so I have to find out how to send a parameter to SQL from whithin a combobox RowSource.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top