Can a button set the form's table/query source?

  • Thread starter Thread starter JBowler
  • Start date Start date
J

JBowler

To put it simply, I have too many forms. There are about 10 forms all the
same but feeding from a different query. There are many fields in it but
only 1 field being queried and that is called Scheme.

Is it possible to have 1 unbound form and set the source query from code on
a button on another form. The flow would be like on a Menu and the user
clicks the button for Scheme X and that opend the unbound form and sets the
source query to qrySchemeX. And the same if the user click the button for
Scheme Y and gets the form based on qrySchemeY.

I considered using form filters and having the user just click the radio
button atop the page but that was confusing for them. They wanted it clear
that it was this Scheme only.

Any suggestions appreciated.

JBowler
 
Yes. You can change the recordsource or sourceobject properties of the
current, subform, or other open form at any time that the controls on that
form don't have focus.

Pushing the button on 1 form, only to change a second form may be even more
confusing though, so I'd suggest using a subform and changing either it's
sourceobject (you'll need to maintain the forms) or it's recordsource
(easier if all the fields are the same, but doable even if they aren't).

The code is:

Forms!FormName.RecordSource = ""

Between the quotes use a SQL string, or table name, or query name.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Thanks. That did exactly what was needed. My Forms just reduced by 9!!

Appreciated.

JBowler
 
Back
Top