Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Auto Load Filter On Form Load

Auto Load Filter On Form Load

Auto Load Filter On Form Load

Hi all,

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?

Thx All


RE: Auto Load Filter On Form Load

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'"

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'"



RE: Auto Load Filter On Form Load

Coool.... thx alot Smudge!!! it works


RE: Auto Load Filter On Form Load

Me.Filter = FilterValues
Me.FilterByOn = True

RE: Auto Load Filter On Form Load

Within the button that opens the form try this:-

in the ON CLICK property put-

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 Sub
    MsgBox Err.Description
    Resume Exit_<ButtonName>_Click
End Sub

In other words it's saying 'open the form and use the filter'

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close