Filter Data in a Form

TaylorDF

New Member
Joined
Apr 26, 2017
Messages
8
Hey,

I've been searching around for about an hour and I can't seem to filter a form to show only certain records based on a pre-defined list of requirements. I have a table with 300 entries and each one has 10 tick boxes and 10 data fields. I would like to add a button on the form when clicked will only show the records that have box1 and box2 ticked but still show all off the existing fields.

Using SQL I managed to make a query

'SELECT * FROM test1 WHERE [Quoted?] = True AND [Chased?] = FALSE'

although when I tried to put it into a macro

'Private Sub Command319_Click()

Dim SQL As String
SQL = "SELECT * FROM test1 WHERE [Quoted?] = True AND [Chased?] = False"


DoCmd.RunSQL SQL

End Sub'

But I can't get it to work.

Any help would be appreciated

Thanks,

Taylor
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Are you trying to set the active form to filter based on this?

If so something like:

Code:
Dim SQL As String
SQL = "SELECT * FROM test1 WHERE [Quoted?] = True AND [Chased?] = False"
Me.RecordSource = SQL

if not then you will need to reference the form you want to update: Forms!myform.RecordSource = SQL

the RunSQL command wont create a new query and open it - it will just run the SQL in the background... ideal for an update or append query but useless for select. To do this you need to have a query already there, update the QueryDef and then use OpenQuery to open it.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top