INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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!

*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.

Jobs

Form Basics

Filter a report from a form button with no query by guitardave78
Posted: 10 Apr 03 (Edited 14 Apr 03)

This is taken from MSDN and is just the code that i have used and a link to the MSDN article.  
This is useful if the form data may be filtered on many different fields, reducing the need for lots of if statements and different queries!!


Code:
'**in general declarations add**
Dim iFilterType As Integer

'**On Click**
Private Sub Button_Click()
Dim fil As Form
Dim stDocName As String
stDocName = "Student_Course"
'**The report you wish to preview**
Set fil = Forms![StudentID1]'**The form you have added the button to**


If iFilterType = acApplyFilter Then
    DoCmd.OpenReport stDocName, acPreview, , fil.Filter
'**If a filter has been set on the form then apply it to the report**

Else
    DoCmd.OpenReport stDocName, acPreview
'**If there is no filter then just generate the normal report**
    End If
    
End Sub

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
iFilterType = ApplyType
End Sub


The Link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnimo00/html/o2k00a4.asp

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Resources

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