sounds like you want to pull a subset of records from a table, by setting
criteria on certain fields, and display those particular records in a
report - and you want to use unbound controls on a form to provide the
query
criteria, so that your user can choose specific criteria values at
runtime.
is this what you have in mind?
if so, try the following: create the form, which i'll call frmStation.
add
the unbound controls; i added a control for each field you listed for
tblStation, and named each control the same name as the corresponding
field - except i added a "txt" prefix (txtTimeZone, txtUse, txtCity,
etc.).
createa query to 1) pull all fields in the table, 2) allow the user to
select (or not) criteria from every field, and 3) allow the user to pull
records based on the beginning of data values. so entering "Spring" in the
City textbox control would return records where the city name is
Springfield
*or* Springboro *or* Spring Hill. use of the Like operator is perhaps more
suited to a search function; you can always use a strict value comparison
by
removing the Like clauses and simply using direct form/control references.
see the following SQL statement, using your table/field names and my
form/control names, as
SELECT tblStation.*, tblStation.TimeZone, tblStation.Use, tblStation.City,
tblStation.State, tblStation.DMA, tblStation.Affiliate, tblStation.Rank
FROM tblStation
WHERE (((tblStation.TimeZone) Like [Forms]![frmStation]![txtTimeZone] &
"*"
Or [Forms]![frmStation]![txtTimeZone] Is Null) AND ((tblStation.Use) Like
[Forms]![frmStation]![txtUse] & "*" Or [Forms]![frmStation]![txtUse] Is
Null) AND ((tblStation.City) Like [Forms]![frmStation]![txtCity] & "*" Or
[Forms]![frmStation]![txtCity] Is Null) AND ((tblStation.State) Like
[Forms]![frmStation]![txtState] & "*" Or [Forms]![frmStation]![txtState]
Is
Null) AND ((tblStation.DMA) Like [Forms]![frmStation]![txtDMA] & "*" Or
[Forms]![frmStation]![txtDMA] Is Null) AND ((tblStation.Affiliate) Like
[Forms]![frmStation]![txtAffiliate] & "*" Or
[Forms]![frmStation]![txtAffiliate] Is Null) AND ((tblStation.Rank) Like
[Forms]![frmStation]![txtRank] & "*" Or [Forms]![frmStation]![txtRank] Is
Null));
if you're not comfortable with SQL, the above may be daunting. but it's
easily created using the query Design grid. just add the following
criteria
to each field, as
Like [Forms]![frmStation]![txtTimeZone] & "*" Or
[Forms]![frmStation]![txtTimeZone] Is Null
for the Use field, replace [txtTimeZone] in the criteria above with
[txtUse]; for the City field...etc, etc, etc. if you only want to allow
the
user to specify criteria for certain fields, then set the form/control
reference criteria on only those fields in the query.
bind your report to the query, or you could use the SQL statement directly
as the report's RecordSource. on the form, add code to the GO button to
open
the report. if no criteria are chosen, all table records will be returned;
when criteria are specified in one or more textbox controls, only matching
records will be returned.
hth
Bob Watson said:
I think, in general, I know how to do this ...
"this" being placing controls on forms to
drive queries.
Say I have a table with fields
Table: tblStation
Fields: TimeZone
Use
City
State
DMA
Affiliate
Rank
Also, I have a report
rMyReport
I think I need to
1- create a form with edit controls
which are not hooked to table fields
2 - put a GO button on this form
3 - display the form
4 - when the user clicks GO then examine
the edit controls
5 - build a query string based on these values
6 - If a edit control is blank then ignore it in
the query
7 - Apply this query string to the table which
feeds
rMyReport
Is this generally correct?? If someone had an
example of the details of this I would be very
appreciative. I think a VBA module has to interact
with the form, but I am not exactly certain how.
Thanks in advance,
Bob