By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,852 Members | 2,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,852 IT Pros & Developers. It's quick & easy.

Re-using sql Code for access qry

P: 16
I have a form that prints a report based off of a query for a specific table. If I want to use this form for other tables that have similar data but for certain reasons must be kept seperate tables how would I improve on what I am currently doing?

Currently I have a select case statement placed in the Private Sub Report_Open for the report in question that sets the report.recordsource property to an SQL statement version from a query. Basically all the code is the same except for the table name. Is there a way from the qry builder that I can change the table dynamically through code while keeping the fields I have already selected or am I correct in using the method I have in place.

Aug 13 '06 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 14,534
You could pass the table name as a string parameter to a function containing the query builder. The table name could be obtained from a listbox or combobox on the form.
Aug 13 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.