form filter (1 Viewer)

prabhus

Registered User.
Local time
Today, 03:28
Joined
Mar 14, 2012
Messages
67
any time, i open a form i want to apply this two filters
[Query1].BD=Yes And [Query1].BD_Completed=No
i used it in form>property>Data>filter, it was working fine but its often disturbed by the users and filter is not working.

How to do it in a more secure way?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 03:28
Joined
Aug 30, 2003
Messages
36,134
You can base the form on a query that has those as criteria.
 

prabhus

Registered User.
Local time
Today, 03:28
Joined
Mar 14, 2012
Messages
67
Thank you but I can't base the query, because i use the same query for two different forms and the filter criteria is different for two forms.
 

Keith Tedbury

Registered User.
Local time
Today, 11:28
Joined
Mar 18, 2013
Messages
26
You could have a query for each form that is uses your current query as its bases and put the criteria in the new query. By using the current query as the base for the new queries they will stay in sync with each other if you make any changes in the future.

Or I suppose you could set the filter in code when you open the form but I would personally do the above instead but if you do want to set the filter in code its.

would be something like

me.filter ="BD='Yes' And [BD_Completed]='No'"
me.filteron = true
 

Simon_MT

Registered User.
Local time
Today, 11:28
Joined
Feb 26, 2007
Messages
2,176
There is a difference between Forms and Queries. Many Forms can run off one Query. To differentiate data or qualifying the data you apply filter and the best way is when opening the form. You can if you want trasfer the filter between Forms:

Code:
Function ClientsEntry() As String

    DoCmd.OpenForm "Clients Details", acNormal, "", ClientsCriteria, acFormEdit, acWindowNormal
End Function

Then I want to go to a related Form:

Code:
Function ClientsInterestClient() As String

    With CodeContextObject
            DoCmd.OpenForm "Clients Interest Enquiry", acNormal, "", ClientsFilter, acFormEdit, acWindowNormal
            DoCmd.GoToRecord acDataForm, "Clients Interest Enquiry", acGoTo, .CurrentRecord
            DoCmd.Close acForm, "Clients Details"
    End With
End Function

You will note that as this is related you can pick up the current record on the previous form. This is probably too much information!

Simon
 

Users who are viewing this thread

Top Bottom