My mind is at a blank, i want the form to automatically filter out the records for ([TBL Base Data].[Unit Type]="Adross" but what do i put into the Form open for the filter to apply when the form is opened?
If you ALWAYS want the filter to apply then hard code it into the Form's Record Source as in:-
"SELECT * FROM [TBL Base Data] WHERE [Unit Type]= 'Adross'"
Or
If you want to be able to remove the filter later put
"[TBL Base Data].[Unit Type]= 'Adross'"
in the Filter property and set the Allow Filters to Yes
Or If you only want to apply the filter in certain cases then put the following coad in the On_Load event
If Not IsNull(OpenArgs) Then
Me.Filter = OpenArgs
Me.AllowFilters = True
End If
And in the DoCmd.OpenForm that causes the form to open, set the OpenArgs parameter to "[TBL Base Data].[Unit Type]= 'Adross'"
Private Sub _<ButtonName>_Click()
On Error GoTo Err_<ButtonName>_Click
Dim strDocName As String
Dim strFilter As String
strDocName = "<FormName>"
strFilter = "([TBL Base Data].[Unit Type]="Adross""
DoCmd.OpenForm stDocName,, strFilter
Exit__<ButtonName>_Click:
Exit Sub
Err___<ButtonName>_Click:
MsgBox Err.Description
Resume Exit_<ButtonName>_Click
End Sub
In other words it's saying 'open the form and use the filter'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.