Hi Buddies,
I want to open different Access reports by a combobox using DoCmd OpenReport for one(same) criteria at a time.
I use for single report (DoCmd.OpenReport "Combined_Report_1", acViewPreview, , "SR_Pcode=" & Me.txtSR_Pcode)
(I wrote above DoCmd 10 times for 10 different reports, It asks "Enter parameter value" 10 times for same SR_Pcode, it is dull for the user)
First I just select state region name(SR_Name which is alphabetically sorted) from the Combobox
While state region(SR_Name) selected from combobox, respective State Region code(SR_Pcode ) and State Region name (SR_Name_Mya) appear.
Then I click on “Open Report” Button(which is a Subform/Subreport under control group).
The message shows as “Procedure :cmdOpenReport 13 Type mismatch”
My codes are as follows:
Private Sub cmdOpenReport_Click()
Dim SR_List As Database
Dim SR_Name As String
Dim SR_Name_Mya As String
Dim SR_Pcode As String
Dim strCond As String
On Error GoTo Err_Process
If (Not IsNull(Me.cboSR_Name)) Then
DoCmd.OpenReport Me.cboSR_Name, IIf("[SR_Pcode]=" & "'" & Me![txtSR_Pcode] & "'", acViewPreview, acViewNormal)
strCond = Nz("Me.Me.cboSR_Name.Value", " ")
DoCmd.OpenReport "1_SR_Entry_Cost_Report", acViewPreview, , strCond
DoCmd.OpenReport "2_SR_Land_Access_Report", acViewPreview, , strCond
DoCmd.OpenReport "3_SR_Registry_Report", acViewPreview, , strCond
Else
MsgBox "You must select a Township." & vbCrLf & vbCrLf & "Please try again.", vbExclamation, "No Township Selected"
End If
Exit_Process:
Exit Sub
Err_Process:
MsgBox "Procedure: cmdOpenReport" & vbCrLf & vbCrLf & Err.Number & " " & Err.Description, vbExclamation, "Error"
Resume Exit_Process
End Sub
Thanks in advance
I want to open different Access reports by a combobox using DoCmd OpenReport for one(same) criteria at a time.
I use for single report (DoCmd.OpenReport "Combined_Report_1", acViewPreview, , "SR_Pcode=" & Me.txtSR_Pcode)
(I wrote above DoCmd 10 times for 10 different reports, It asks "Enter parameter value" 10 times for same SR_Pcode, it is dull for the user)
First I just select state region name(SR_Name which is alphabetically sorted) from the Combobox
While state region(SR_Name) selected from combobox, respective State Region code(SR_Pcode ) and State Region name (SR_Name_Mya) appear.
Then I click on “Open Report” Button(which is a Subform/Subreport under control group).
The message shows as “Procedure :cmdOpenReport 13 Type mismatch”
My codes are as follows:
Private Sub cmdOpenReport_Click()
Dim SR_List As Database
Dim SR_Name As String
Dim SR_Name_Mya As String
Dim SR_Pcode As String
Dim strCond As String
On Error GoTo Err_Process
If (Not IsNull(Me.cboSR_Name)) Then
DoCmd.OpenReport Me.cboSR_Name, IIf("[SR_Pcode]=" & "'" & Me![txtSR_Pcode] & "'", acViewPreview, acViewNormal)
strCond = Nz("Me.Me.cboSR_Name.Value", " ")
DoCmd.OpenReport "1_SR_Entry_Cost_Report", acViewPreview, , strCond
DoCmd.OpenReport "2_SR_Land_Access_Report", acViewPreview, , strCond
DoCmd.OpenReport "3_SR_Registry_Report", acViewPreview, , strCond
Else
MsgBox "You must select a Township." & vbCrLf & vbCrLf & "Please try again.", vbExclamation, "No Township Selected"
End If
Exit_Process:
Exit Sub
Err_Process:
MsgBox "Procedure: cmdOpenReport" & vbCrLf & vbCrLf & Err.Number & " " & Err.Description, vbExclamation, "Error"
Resume Exit_Process
End Sub
Thanks in advance