Yeah, in that case you should be able to use
Me.Recordsource to change the source for the form.
You could build saved queries for each of your
situations, or you could build the sql statement in code
to generate the recordset that you want.
I have read that using saved queries for forms can be
faster because Access optimizes the saved queries. I
don't know whether it would make a measurable difference
in your case.
If you decide to generate the sql string for the
recordset at run time, it is usually easier to follow to
assign it to a string variable and build it using
whatever necessary logic. Then just set the recordsource
equal to the variable containing the sql string.
A snippet of some code building a very simple sql string
follows (watch wrapping)
strSQL = "SELECT tFADetail.* FROM tFADetail "
strSQL = strSQL & "WHERE tFADetail.WO_No = '" & strWO
& "'"
You can go to sql view of your existing queries to look
at their sql statements. The idea would be to either
build them in code based on some input, or just select
one based on which button was pressed, or something
similar.
So, you can use If statements and other conditional
evaluation tools to generate the sql that you want, then
set that as your form's record source.
To answer your other earlier question, you can set
anything valid as your form's record source in the design
view, that will just define the form's initial view and
your code will directly change it at run time per your
established event triggers.
HTH
-Ted Allen
-----Original Message-----
Thx Ted.
The form is based on a single table, or a tmp table with
the same fields. I'd like to use multiple querys, or
recordsets build from my code, then set the recordset =
in some logic. All recordsets and tables have the same
field names. I was just unclear of how to select the
data differently, then present it using one form and not
have to use a different form for each query or recordset
in a program. I hope that makes more sence. - Mike