Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unbound Form that can run one of two reports

Status
Not open for further replies.

Jacqui3

MIS
May 8, 2002
13
0
0
ZA
Hi,

I have an unbound form which the user selects a projectcode from and this currently runs a report.

I now need to change this form to run one of two different reports -
(1) I now need to identify in the project table the billingindicator for the projectcode selected, and then decide
(2) if the billingindicator is yes then run report A else run report B .

Any suggestions on how to do this?

 
Hi!

Make a button to run the required report and in the button's click event use the following code:

Dim bolBilling As Boolean

bolBilling = DLookUp("BillingIndicator", "ProjectTable",
"ProjectCode = '" & Me!cmbProjectCode & "'")

If bolBilling = True Then
Print the first report
Else
Print the other report
End If

All of the names of controls, fields and tables will need to be changed to match what is in your database.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Hi,

I tried what you gave me but I get the following error:
"The expression you entered as a query parameter produced this error: 'The object doesn't contain the Automation object 'BillingIndicator.'"

What does this mean???

Here is my code:

Private Sub txtPreviewWAreport_Click()
On Error GoTo Err_txtPreviewWAreport_Click

Dim stDocName As String
stDocName = "Work Authorisation Report"

Dim bolBilling As Boolean

bolBilling = DLookup("BillingIndicator", "Project", "ProjectCode = '" & Me!txtProjectCde & "'")

If bolBilling = True Then
DoCmd.OpenReport stDocName, acPreview
Else
Print the; other; Report
End If

Exit_txtPreviewWAreport_Click:
Exit Sub

Err_txtPreviewWAreport_Click:
MsgBox Err.Description
Resume Exit_txtPreviewWAreport_Click

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top