Changing a Forms Query

davesmith202

Employee of Access World
Local time
Today, 04:29
Joined
Jul 20, 2001
Messages
522
I have a switchboard with 3 buttons. Each button opens the same Form, but I would like the Query to be different.

How can I do this?

Thanks,

Dave
 
What is different about the queries that won't affect the controls on the form?
 
Bit confused by what you mean. The Queries have the same fields on them as the controls on the Form, so that shouldn't be an issue, yes?
 
If so what makes one query different from the other?
 
Examples are Query1 is based upon another Query with Totals and criteria, whereas Query 2 is based upon a table with just different criteria. Does that help?
 
What you would need to do is to pass the results of the button click to a public variable then on the onload of the form get it to set the recordsource based on the contents of the variable.

For example give each button a value 1 , 2 & 3 and pass this to the public variable

Code:
Form OnLoad Event

Select Case <<Variable>>
   Case 1
      Me.RecordSource = "Query1"
   Case 2
      Me.RecordSource = "Query2"
   Case 3
      Me.RecordSource = "Query3"
End Select

End sub
 
alternatively if you have a form/subform and want to swap in a different subform (as opposed to a different recordsource), then that uses

me.sourceobject

rather than me.recordsource
 

Users who are viewing this thread

Back
Top Bottom