creating a recordset from button

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

I was to use a button which when the user presses - filters the records
based on a query (or SQL). Can for the life of me think how to do it

thanks

Alex
 
Alex said:
I was to use a button which when the user presses - filters the records
based on a query (or SQL). Can for the life of me think how to do it
The recordset for the form must be set to the results or your query.
 
not clear on your setup. do you have a form bound to a
table or query, and want to filter the form records when
the user clicks a command button?

if so, open the form in design view, click on the Filter
property line (right below the RecordSource line), then
press F1 to see the Help topic. after reading up on the
Filter property, just put your

Me.Filter = ...
Me.FilterOn = True

code in the command button's OnClick event procedure.

there are other ways to filter a form's records, depending
on the situation. if the above doesn't suit, post back
with more detail on your setup.
 
Hi Tina - thanks for your input

I have a form, which also contains a subform. When the form is loaded it is
based on a query to get the data into the correct order.

On the main form i have a button, which onClick I want to filter the
existing recordset and display the results in the form.

following youi suggestion, I have an Event procedure in the OnClick event of
the button and the following code:
Me.Filter = "County = 'Devon'"
Me.FilterOn = True

However, when I click the button, nothing happens

any help much appreciated

Alex
 
well, sounds like it should work just fine. your main
form's RecordSource is a query, right? and you're trying
to filter the main form's recordset, right? and "County"
is a field in the RecordSource query, right? and you're
not getting an error message, just a big dud, right?

did you try stepping through the code to make sure it's
running?
 
Back
Top