filter form only by clicking button (1 Viewer)

Ricky8888

New member
Local time
Today, 03:49
Joined
Jun 22, 2012
Messages
4
Hello and many thanks to all posters. You've saved my live so many times!

Now I have question which I didn't find solution so far. And I think that's so simple... But don't laugh.... :)

I work on very complicated app for tourist agency and have one form with tab control on it. Every Page has its on data source based on query, and they aren't related to Parent form or to each other. I want to set few buttons on every Page which would filter records in predefined way.

Ex: one page has calculated field named [Za platiti]. It has numeric values form 0 up. I want to set one button to filter only records where field [Za platiti] is greater then 0, and other butt to filter only records where [Za platiti] is = 0.

Other filters based on combo box I use regularly, but that's one what I stuck on!

Many thanks in advance!
 
Last edited:

Mr Smin

Sometimes Excel too.
Local time
Today, 10:49
Joined
Jun 1, 2009
Messages
132
You can add a parameter to the query that refers to the form and use a button on the form to change a value and then refresh the results.
In the query:
[Za platiti]>=Forms![NameOfYourForm]![txtYourValue]

On the form, a text box called txtYourValue, with a default of 0
A button with onClick event
that says
Me!txtYourValue=1
DoCmd.Me!Requery

the query then runs again with the new value.

Sorry this is not very detailed as I don't have an example to hand.
 

Ricky8888

New member
Local time
Today, 03:49
Joined
Jun 22, 2012
Messages
4
You can add a parameter to the query that refers to the form and use a button on the form to change a value and then refresh the results.
In the query:
[Za platiti]>=Forms![NameOfYourForm]![txtYourValue]

On the form, a text box called txtYourValue, with a default of 0
A button with onClick event
that says
Me!txtYourValue=1
DoCmd.Me!Requery

the query then runs again with the new value.

Sorry this is not very detailed as I don't have an example to hand.


Thank you! I'll try that way, but I don't know how to set same query with the second Button which I'd like to show all records where [Za platiti] = 0. Should I use 'or' option in that Qry?

Tnx anyway, I'll try and maybe got an idea!
 

Mr Smin

Sometimes Excel too.
Local time
Today, 10:49
Joined
Jun 1, 2009
Messages
132
You could have a second button to show [Za platiti] = 0 which would be

Me!txtYourValue=0
DoCmd.Me!Requery
 

Ricky8888

New member
Local time
Today, 03:49
Joined
Jun 22, 2012
Messages
4
Thank you Mr Smin, I found similar solution.... Two buttons made changes in one field which values I use as a criteria in query.... Got all pieces together!
 

boblarson

Smeghead
Local time
Today, 03:49
Joined
Jan 12, 2001
Messages
32,059
A simpler method is to just use the form's Filter property

Code:
Me.Filter = "[Za platiti] > 0"
Me.FilterOn = True

Code:
Me.Filter = "[Za platiti] = 0"
Me.FilterOn = True
 

Ricky8888

New member
Local time
Today, 03:49
Joined
Jun 22, 2012
Messages
4
A simpler method is to just use the form's Filter property

Code:
Me.Filter = "[Za platiti] > 0"
Me.FilterOn = True

Code:
Me.Filter = "[Za platiti] = 0"
Me.FilterOn = True

Thanks Bob! That's simpler, but I decided to use query because in that case my data is ready for printing and I can use same query for report.
 

Users who are viewing this thread

Top Bottom