Hi, I have a popup form that ask do you want to print all departments or selected departments?
the user enters the beg dept (10) and then the end dept. (30)then they click on the preview button. Which should open a report with the the beg dept Thru the end dept displayed But i get the following error:
a syntax error (missing operator in query expresion)
here is the code:
-------------------------------
Private Sub btnPreviewReport_Click()
On Error GoTo Err_btnPreviewReport_Click
Dim stDocName As String
Dim stCriteria As String
If Me![DeptOptionGroup] = 2 And (IsNull(Me![cbxBegDept]) Or IsNull(Me![cbxEndDept])) Then
MsgBox "You Must Select a Beg Dept and End Dept. Please Make A selection in the Beg Dept and End Dept and try again.", , "BEG / END DEPARTMENT ERROR"
Me![cbxBegDept].SetFocus
Me![cbxBegDept].Dropdown
Exit Sub
End If
If Me![DeptOptionGroup] = 2 Then
stCriteria = "[JobCodeDept] = BETWEEN [cbxBegDept] And [cbxEndDept]"
End If
If Me![PageLayoutOptionGroup] = 2 Then
stDocName = "rptJobCodesPerPage"
Else
stDocName = "rptJobCodes"
End If
DoCmd.OpenReport stDocName, acPreview, , stCriteria
Exit_btnPreviewReport_Click:
Exit Sub
Err_btnPreviewReport_Click:
MsgBox Err.Description
Resume Exit_btnPreviewReport_Click
End Sub
----------------------------------
Thanks
the user enters the beg dept (10) and then the end dept. (30)then they click on the preview button. Which should open a report with the the beg dept Thru the end dept displayed But i get the following error:
a syntax error (missing operator in query expresion)
here is the code:
-------------------------------
Private Sub btnPreviewReport_Click()
On Error GoTo Err_btnPreviewReport_Click
Dim stDocName As String
Dim stCriteria As String
If Me![DeptOptionGroup] = 2 And (IsNull(Me![cbxBegDept]) Or IsNull(Me![cbxEndDept])) Then
MsgBox "You Must Select a Beg Dept and End Dept. Please Make A selection in the Beg Dept and End Dept and try again.", , "BEG / END DEPARTMENT ERROR"
Me![cbxBegDept].SetFocus
Me![cbxBegDept].Dropdown
Exit Sub
End If
If Me![DeptOptionGroup] = 2 Then
stCriteria = "[JobCodeDept] = BETWEEN [cbxBegDept] And [cbxEndDept]"
End If
If Me![PageLayoutOptionGroup] = 2 Then
stDocName = "rptJobCodesPerPage"
Else
stDocName = "rptJobCodes"
End If
DoCmd.OpenReport stDocName, acPreview, , stCriteria
Exit_btnPreviewReport_Click:
Exit Sub
Err_btnPreviewReport_Click:
MsgBox Err.Description
Resume Exit_btnPreviewReport_Click
End Sub
----------------------------------
Thanks