Base a form on a recordset in Access 97

  • Thread starter Thread starter Tim O'Mahony via AccessMonster.com
  • Start date Start date
T

Tim O'Mahony via AccessMonster.com

Hi all,
First post here and I'm somewhat of a novice.
I'm using Access 97 and need users of a database to be able to view the
results of a query on a form. However, the query parameters themselves are
chosen on the form by the use of three comboboxes.
I can construct the sql statement in VBA (with the comboboxes' selected
values) but I don't know how to set the resulting recordset of this query
to be the form's recordsource. Essentially, the query runs but I don't know
how to display it on a form.
Any directions are greatly appreciated.

Thanks alot
 
use the query as the form's RecordSource rather than using a table. You'll
need to requery the form after the parameters are selected in the combos.
When the form first opens, it will be empty since the combos will be null.
If you had only one combo, you could use the AfterUpdate of the combo to
requery the form but since you have three combos, you should probably use a
button.
 
Thanks Pat,
I cannot set the query as the recordsource at the outset (in the property
sheet) as this "locks in" the query particulars, including the table. One
of the combo boxes must choose the table at runtime.
If I can name the sql string at runtime as a query, I could then set the
form's recordsource to this query, also at runtime. However, I don't know
how to do this.
 
Thanks Pat,
However, the problem that I have is referring to the sql string as a query
on the fly, not the recordset. I could then set the form's text boxes,
immediately afterwards, to queryname!field. Cycling through the form will
then display the dynaset, record-by-record.
Thanks again
 
Pat,
I worked it out. Thanks for your help. I appreciate it.

Tim
 
Back
Top