Changing the Record Source from within a subform

atrium

Registered User.
Local time
Tomorrow, 04:32
Joined
May 13, 2014
Messages
348
Can I change the Records Source of a subform from within that subform and do a requery to have a different set of records displayed'

I want to be able to refine the records displayed in the subform
 
How can I do that in VBA, as the event taken when a button is clicked on
 
Sorry for being a bit slow - it's been a long day

I like to know how to do it both ways if I can

Regards
 
To change the record source try:
Me.RecordSource = "queryname"
To apply a filter try something like:
DoCmd.ApplyFilter , "NameOfFieldToBeFiltered= 'TextToBeFilteredBy'"
You would NOT need the single quotes if the value is numeric.
 
Thanks Bob I'll get onto that today
 
I tried it in the subform but it applied it to the mainform.
How do I get to just apply to the form

This is the code I used

Private Sub Command50_Click()
DoCmd.ApplyFilter , "Operator = 11"
Refresh
End Sub
 
I got around it Bob by using the

Me.RecordSource = "queryname" and using a variable in the query for each operator selected from a drop down

Thanks for all your help

Regards
 

Users who are viewing this thread

Back
Top Bottom