Query based on dropdown selection

A

AnotherNewGuy

Access 2003

I have very simple form with one ComboBox to select software titles. I just
want to see every computer with a specific piece of software installed. If
someone could explain why queries run from the form return nothing, I'd sure
appreciate it.

Query is "Software Search"
Form is "Software Search"
Combox box is "SoftwareList"

Criteria of the query is "Like [forms]![software search]![softwarelist]"

I can select from the list and run the query from a command button and get
nothing, but I can run the query outside the form and type in a name, and it
works fine.

The following is the code for the On Click event of the button:
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click

Dim stDocName As String

stDocName = "Software search"
DoCmd.OpenQuery stDocName, acNormal, acReadOnly

Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub
 
K

KARL DEWEY

Open the query in design view and scroll to the right to a blank column.
Paste the following in the Field row of the grid --
Just Checking: [forms]![software search]![softwarelist]
Remove the criteria. Do not save.
Use the ComboBox to select a software title. Run the query and see what
appears in the "Just Checking" field. Is it what is required as criteria?
 
A

AnotherNewGuy

Well, no, it's not. That little experiment told me exactly what I was doing
wrong; I was convinced it wasn't passing the parameter to the query. You
probably already knew it was pulling the wrong field from the Software Titles
table. A quick change to the Bound Column solved the problem.

Instead of just answering the question, you told me how to figure it out
myself. Thanks loads.

KARL DEWEY said:
Open the query in design view and scroll to the right to a blank column.
Paste the following in the Field row of the grid --
Just Checking: [forms]![software search]![softwarelist]
Remove the criteria. Do not save.
Use the ComboBox to select a software title. Run the query and see what
appears in the "Just Checking" field. Is it what is required as criteria?

--
KARL DEWEY
Build a little - Test a little


AnotherNewGuy said:
Access 2003

I have very simple form with one ComboBox to select software titles. I just
want to see every computer with a specific piece of software installed. If
someone could explain why queries run from the form return nothing, I'd sure
appreciate it.

Query is "Software Search"
Form is "Software Search"
Combox box is "SoftwareList"

Criteria of the query is "Like [forms]![software search]![softwarelist]"

I can select from the list and run the query from a command button and get
nothing, but I can run the query outside the form and type in a name, and it
works fine.

The following is the code for the On Click event of the button:
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click

Dim stDocName As String

stDocName = "Software search"
DoCmd.OpenQuery stDocName, acNormal, acReadOnly

Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub
 

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