Run Report A or B based on Item in Table

  • Thread starter Thread starter d_diddy
  • Start date Start date
D

d_diddy

Guest
Hi, I have a menu table and a table that feed my reports and my menu table has a field in it that will be either yes or no. What i need to be able to do is to click a button on a form, then i need it to open either report A if that field my menu table is yes or report B if that field is no, i've tried to modify the button click vb using dlookup and it keeps telling me "argument not optional". Is there a way to do this?
 
I would create 2 queries. Specify in each query either Yes or No for the Yes/No field. Then you will have 2 record sets to populate your report.

Dave
 
Sorry but i already have 2 separate reports based on this, i just need the button to run the report based on what the user specified earlier i.e yes then run report a or if no then run report b
 
in the Click event of your button, enter something like ...

Private Sub btn_OK_Click()
On Error GoTo Err_btn_OK_Click
Me.Visible = False
Dim strReportName As String

Select Case Me![fld_FieldName]
Case "yes": strReportName = "Report_A"
Case "no": strReportName = "Report_A"
End Select

DoCmd.OpenReport strReportName, acViewPreview


Exit_btn_OK_Click:
Exit Sub

Err_btn_OK_Click:
Select Case Err.Number
Case Else: MsgBox Err.Number & vbCrLf & Err.description
End Select
Resume Exit_btn_OK_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom