UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Setting Up Applyfilter Command Button, Access 2016    
 
   
kaylahansa
post Mar 15 2020, 12:36 AM
Post#1



Posts: 4
Joined: 12-January 20



Hello all!

I have a table created called AllCustomers. I also have several other tables for different customers types (for example: CameraCustomers, NetworkCustomers, ect) with a one to many relationship from the AllCustomers table. Each customer type has their own table because there are many different fields for each customer type and each customer may fall under more than one type. I have created a continuous form based on the AllCustomers table. I have also created a query that filters AllCustomers by only those who are a camera customer. I want to have a button on the form that will filter the form to only display the camera customers. My questions is what kind of code do I need for the OnClick event of the button to accomplish this? Is there a macro I can use? The database I'm building will be used for fairly basic features and I would like to keep it's structure as simple if possible.

Any help is greatly appreciated!
Go to the top of the page
 
June7
post Mar 15 2020, 01:57 AM
Post#2



Posts: 1,304
Joined: 25-January 16
From: The Great Land


You don't need that query. Apply filter criteria to form Filter and FilterOn properties.

What field in AllCustomers indicates customer type?

Me.Filter = "fieldname='Camera'"
Me.FilterOn = True

Might find this tutorial of interest http://allenbrowne.com/ser-62.html

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Go to the top of the page
 
projecttoday
post Mar 15 2020, 02:32 AM
Post#3


UtterAccess VIP
Posts: 11,782
Joined: 10-February 04
From: South Charleston, WV


This isn't necessary. Put all possible customer values in one table and on one form. If the form is too crowded, use a tab control to separate the different types of information.

--------------------
Robert Crouser
Go to the top of the page
 
Bullschmidt
post Mar 25 2020, 08:27 PM
Post#4



Posts: 29
Joined: 8-May 19
From: USA


QUOTE
I have created a continuous form based on the AllCustomers table. I have also created a query that filters AllCustomers by only those who are a camera customer. I want to have a button on the form that will filter the form to only display the camera customers. My questions is what kind of code do I need for the OnClick event of the button to accomplish this? Is there a macro I can use? The database I'm building will be used for fairly basic features and I would like to keep it's structure as simple if possible.


Seems like your query could have criteria for the CustomerType field of something like:
Like [Forms]![MyForm]![txtCustNumChooser]

And the form's txtCustNumChooser combobox could have a DefaultValue of ="*" so that the Like criteria in the query would initially show all records (although a customer with a blank CustType would not actually be shown).

And then if the user changes the txtCustNumChooser combobox to something like Camera you would want that to trigger a requery of the form so in the control's OnExit perhaps have code like this:
Me.Requery

Or if you have a button that opens a form that is based on the query then don't need to do a requery - just open the form normally.

Hopefully this might give you some ideas to try while still keeping things relatively simple...

--------------------
J. Paul Schmidt - Freelance Web and Database Developer
Sample Database on the Web
Sample Access Database

Go to the top of the page
 
Bullschmidt
post Mar 25 2020, 09:09 PM
Post#5



Posts: 29
Joined: 8-May 19
From: USA


Or perhaps better yet but slightly more complicated change the criteria for the CustomerType field of something like:
Like [Forms]![MyForm]![txtCustNumChooser]

To be more like this instead:
Like IIf(IsNull([Forms]![frmInvRptDlg]![InvCustNum]),"*",[Forms]![frmInvRptDlg]![InvCustNum])

And then you don't even need to put in a DefaultValue of ="*" as a blank will cause all the records to be shown (except for anything with a blank in the field used as criteria).

But also looking back again at June7's suggestions those really do seem short and sweet, but maybe some of the ideas above could be used in conjunction with that too...

--------------------
J. Paul Schmidt - Freelance Web and Database Developer
Sample Database on the Web
Sample Access Database

Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    29th March 2020 - 04:23 AM