Passing a form parameter to a group of queries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have about 50 queries and they all do the same thing except they run off of
different tables. I have a form that when executed will run all the queries
in succession. I do not want to always report on all historic data, so I
would like to put a date parameter on the form and have it passed to each
individual query. Any ideas?
 
Why not use VBA instead of queries

docmd.runsql "UPDATE MyTable1 SET MyDate = #" & Me.DateFieldName & "#"
docmd.runsql "UPDATE MyTable2 SET MyDate = #" & Me.DateFieldName & "#"
docmd.runsql "UPDATE MyTable3 SET MyDate = #" & Me.DateFieldName & "#"

or if you still want to use queries then put a reference to the form
docmd.runsql "UPDATE MyTable1 SET MyDate = Forms![FormName]![DateFieldName]


For all the tables you want to update
 
One approach: 1) assign the value of your parameter to a global variable in
VB 2) create a public function in VB that returns that global variable 3)
add that function your queries as a Criteria of the appropriate fields.
 
Why do you have 50 tables with the same kind of data in them? (I assumed
this from your description -- if incorrect, please disregard.) Could you
describe what kind of data you have split among these tables?

Good luck

Jeff Boyce
<Access MVP>
 
Back
Top