Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

attaching different queries to a single form 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hello,

Is it possible to have a single form but when the menu option in the switchboard is selected pass in the name of the query you want to attach as the datasource.

The problem I have is the database contains 'members', 'X-members', 'propects' etc.. the boss isn't capable of filtering the DB when he wants to see just 'members' and now thinks the database is clogged up with 'prospects' (baring in mind we use SQL server as the back end DB and the database only has 745 records, I think you can see what i'm up against!)

So instead of spending the next 6 months re-writing the system for one user's computer illiteracy, i want to simply filter out the records dependent on which menu option is selected.

This way i can have a menu option 'Members Only' an option 'Prospects / Withdrawn' and an option 'X-Members' all using the same form just with different queries attached.

So the question now is how do I programatically change the datasource of a form before opening the form, or what can i put in the on-open event to attach the required datasource query.

hope that makes sense.

Regards,
1DMF.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
You will want to make your menu options tied to different queries somehow, I am not sure how many you have but I would just use a select case if there are not too many menu options. Duh! I just re-read, and since you only have 3 it seems select case is the way to go.

Then within each case you just need to set the recordsource for the form based on what's selected ie:

Code:
me.RecordSource = "select * from zeTable where something = 'something'"

Hope this helps,

ALex

Ignorance of certain subjects is a great part of wisdom
 
works a treat , many thanks!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top