Hi there,
I think a better route overall maybe to create reports based off your queries. Except remove the portion of the where clause that equates the user entered value.
Using the Docmd.OpenReport command you can specify the rest of the where statement.
Here's an example of using the Where Condition parameter of the openreport command.
Let's assume we have a report based off this simple query for a book catalogue.
-
SELECT bookID, bookName, bookAuthor, bookLength, bookCoverType
-
FROM tblBook
-
-
Docmd.OpenReport "rptBookListing", acViewNormal,, "[bookAuthor] = 'Jared'",acWindowNormal
-
If you don't want to make reports you can include form fields as part of a where clause.
Let's use the same query as above mention and add a where clause that will be based off the textbox off a form.
-
SELECT bookID, bookName, bookAuthor, bookLength, bookCoverType
-
FROM tblBook
-
WHERE bookAuthor = Forms!frmBook!txtAuthor
-
Forms is the collection of open forms.
frmBook is the name of your form
txtAuthor would be a control on your form i.e. a text box