I have a form with a field where the user enters a SiteID and there are also two option buttons for the user to select if they want the reports to be previewed or printed. There are several command buttons on the form and each one opens or prints a different report based on what the user needs. I'm trying to add a new command button that will open one report if the site is in Texas or New Mexico and a different report if the site is in Oklahoma. When I run the code, I get an error: Too few parameters. Expected 1. I've checked all the spelling and everything is correct. There is one query that is used by both reports and the query runs and both reports open correctly when run/opened directly.
Thanks in advance.
Code:
Private Sub cmdOverfill_Inspection_Click()
On Error GoTo Err_cmdOverfill_Inspection_Click
Dim stDocName As String
Dim stDocName1 As String
Dim RS As DAO.Recordset
stDocName = "rptOverfill_Inspection_Template_NMorTX"
stDocName1 = "rptOverfill_Inspection_Template_OK"
Set RS = CurrentDb.OpenRecordset("qryOverfill_Inspection_Template")
If ([SiteState] = "TX" Or "NM") And (optPreview_or_Print = 1) Then
DoCmd.OpenReport stDocName, acPreview
ElseIf ([SiteState] = "TX" Or "NM") And (optPreview_or_Print = 2) Then
DoCmd.OpenReport stDocName, acprint
ElseIf ([SiteState] = "OK") And (optPreview_or_Print = 1) Then
DoCmd.OpenReport stDocName1, acPreview
ElseIf ([SiteState] = "OK") And (optPreview_or_Print = 2) Then
DoCmd.OpenReport stDocName1, acprint
End If
Exit_cmdOverfill_Inspection_Click:
Exit Sub
Err_cmdOverfill_Inspection_Click:
MsgBox Err.Description
Resume Exit_cmdOverfill_Inspection_Click
End Sub