View Full Version : simple vba script? open different report depending on input


Sprawl
05-15-2007, 06:19 AM
Seems simple i would think.

Two reports one for multiple clients, one for just a single client. I want to do it from 1 page, but with one button (for idiot proofing).

The entry page has inputs. a beginning client and an end client. the if statement should check to see if they're the same. if they are, open the single client report, if they're different, open the multiple client report. This is what i've written but it always tells me that there's missing a =

Private Sub Command11_Click()
IIf([E_CLIENT]=[S_CLIENT], DoCmd.OpenReport("AR - Statement - Single", acViewPreview), DoCmd.OpenReport("AR - Statement", acViewPreview))
End Sub

boblarson
05-15-2007, 06:23 AM
IF Me!E_CLIENT=Me!S_CLIENT Then
DoCmd.OpenReport "AR - Statement - Single", acViewPreview
Else
DoCmd.OpenReport "YourOtherReportNameHere", acViewPreview
End If

Sprawl
05-15-2007, 06:30 AM
boblarson.

as always you're quick to respond and respond you do with the correct solution

Thanks again!

Moniker
05-15-2007, 02:14 PM
Or, all in one line (and because I like switches over If..Then statements):

DoCmd.OpenReport Switch(Me!E_Client=Me!S_CLIENT,"AR - Statement - Single", True, "YourOtherReportNameHere"), acViewPreview