VB Procedure Onclick Button to open Report

D

dan.cawthorne

I've been trying to write a bit of code that will print a particular
report, if the form fiters are active, if not all records are
displayed and i cant get it to work I've tried the following

Private Sub CmdPrintList_Click()
If Me.FilterOn = True ( <------------------------------That line is
Giving me a GoTo Error)

DoCmd.OpenReport "View All Projects", acViewPreview, , Me.Filter

Else: Me.FilterOn = False

DoCmd.OpenReport "View All Projects", acViewPreview
End If

End Sub
 
S

SteveM

Try this:

Private Sub CmdPrintList_Click()
If Me.FilterOn = True Then
DoCmd.OpenReport "View All Projects", acViewPreview, , Me.Filter
Else
DoCmd.OpenReport "View All Projects", acViewPreview
End If
End Sub

Steve
 
D

dan.cawthorne

Try this:

Private Sub CmdPrintList_Click()
If Me.FilterOn = True Then
DoCmd.OpenReport "View All Projects", acViewPreview, , Me.Filter
Else
DoCmd.OpenReport "View All Projects", acViewPreview
End If
End Sub

Steve

Thanks Steve, So I See I Missed the "Then" Word Feel Like a Fool!
 
D

dan.cawthorne

You'll not do it again will you! :)

Steve

It Was My First Attempt a making my own IF type Piece a Code, Its
quite logical really when you get your head round it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top