B
Ben
Hello,
I'm fairly new to Access, so maybe there's a better way to do what I'm
trying to do, but here it is...
I'm an engineer and I'm making a database to store results and setup
info for tests peformed.
1 function of the db is to be able to search for test results. I want
users of the db to be able enter as many or as few criteria, selected
from combo boxes and entered in text boxes on a form, as they choose
(about 6 form fields total, including TestNumber, TestDate,
PartNumber, TestDescription, etc). The search form would have 2 main
areas: 1st they would select the criteria that must be matched in the
tables of test results, 2nd they would choose which specific fields
will be displayed on the report (which is intended to be printed on
8.5x11)
The end result I'd like is a report listing the test results. I'm
trying to avoid hard coding all the different queries. I want an sql
statement to be generated as the form is filled out. Once a "Search"
button is hit the SQL statement would do what it does to query the
results from basically 2 tables, including only the fields selected by
the user. Then a report would automatically open, reading from the
query that was made.
I've tried using "DoCmd.RunSQL" in the OnClick code of the "search"
button with very little luck. Here's an example of me trying to select
all the tested seats of either program A or B:
Dim SQL_Text As String
SQL_Text = "SELECT tblSeats.*, tblSeats.ProgramID " & _
"FROM [tblSeats] " & _
"WHERE (((tblSeats.ProgramID)='A' Or (tblSeats.ProgramID)='B'));"
DoCmd.RunSQL SQL_Text, False
I then get an error like:
"A RunSQL action requires an argument consisting of an SQL statement"
One problem is I don't really understand what RunSQL is doing... is it
creating a new querty object? If not, can the results even by used for
a report?
I've also tried linking the search form to a table with a field for
each field in the form. Each time a new search was entered, the form
deleted the table's data, and entered the new criteria...the table
only kept the 1 record. This record was then used for the WHERE clause
in my report query. This allowed for no flexibility because all of the
search criteria had to be selected, allowing only for very limited and
narrow search results.
Any help, whether specific examples or general db practices, is
appreciated.
Thanks.
I'm fairly new to Access, so maybe there's a better way to do what I'm
trying to do, but here it is...
I'm an engineer and I'm making a database to store results and setup
info for tests peformed.
1 function of the db is to be able to search for test results. I want
users of the db to be able enter as many or as few criteria, selected
from combo boxes and entered in text boxes on a form, as they choose
(about 6 form fields total, including TestNumber, TestDate,
PartNumber, TestDescription, etc). The search form would have 2 main
areas: 1st they would select the criteria that must be matched in the
tables of test results, 2nd they would choose which specific fields
will be displayed on the report (which is intended to be printed on
8.5x11)
The end result I'd like is a report listing the test results. I'm
trying to avoid hard coding all the different queries. I want an sql
statement to be generated as the form is filled out. Once a "Search"
button is hit the SQL statement would do what it does to query the
results from basically 2 tables, including only the fields selected by
the user. Then a report would automatically open, reading from the
query that was made.
I've tried using "DoCmd.RunSQL" in the OnClick code of the "search"
button with very little luck. Here's an example of me trying to select
all the tested seats of either program A or B:
Dim SQL_Text As String
SQL_Text = "SELECT tblSeats.*, tblSeats.ProgramID " & _
"FROM [tblSeats] " & _
"WHERE (((tblSeats.ProgramID)='A' Or (tblSeats.ProgramID)='B'));"
DoCmd.RunSQL SQL_Text, False
I then get an error like:
"A RunSQL action requires an argument consisting of an SQL statement"
One problem is I don't really understand what RunSQL is doing... is it
creating a new querty object? If not, can the results even by used for
a report?
I've also tried linking the search form to a table with a field for
each field in the form. Each time a new search was entered, the form
deleted the table's data, and entered the new criteria...the table
only kept the 1 record. This record was then used for the WHERE clause
in my report query. This allowed for no flexibility because all of the
search criteria had to be selected, allowing only for very limited and
narrow search results.
Any help, whether specific examples or general db practices, is
appreciated.
Thanks.