Help - How to use a Button to change a form data source

russ1985

Registered User.
Local time
Tomorrow, 00:32
Joined
Mar 12, 2009
Messages
18
I have a form which i want to be able to click a command button and it change the record source of the form from a specific table to a query (which will ask for a parameter to search the table and change the form to show the matching record).

can anyone help with some ideas for coding the button to do this.

Skill level - Beginner/Intermediate
software: Access 2007
system: Vista :( (miss XP, cant afford 7)
 
In the OnClick event of a command button...

Code:
Me.RecordSource = "Your Query or SQL"
Me.Requery [COLOR="Green"]'Not sure if you have to requery but just in case.[/COLOR]
 
I have a form which i want to be able to click a command button and it change the record source of the form from a specific table to a query (which will ask for a parameter to search the table and change the form to show the matching record).

can anyone help with some ideas for coding the button to do this.

Skill level - Beginner/Intermediate
software: Access 2007
system: Vista :( (miss XP, cant afford 7)

Out of curiosity, why not just base the form off of the query anyway? or use a combo box that uses the query that will find the record you want? Then you wouldn't have to code a record source change.
 
Hi Thanks for the code worked a treat.

to answer your question i want to save the user needing to open a different form for different queries and tables. much better to just have a button to change the record source to run from a different table/query.

thanks again.
 

Users who are viewing this thread

Back
Top Bottom