G
Guest
I have created a string of code to have the buttom run a group of report
determined on what the user selects. However, when I add the combox using
the field Record ID it will not work. When I us all the other option by them
self or as a group they will work. But as soon as I add the Record ID it
will not work. The Record ID is a autonumber field. It is how I save the
records. Can anyone look at the code and see if they have any suggestions.
Private Sub CmdSafety_Click()
Dim stDocNameSRBF As String
Dim stDocNameSRBI As String
Dim stDocNameSRBN As String
Dim stDocNameSRBT As String
FM = Me!CboFM
ID = Me!CboID
NH = Me!CboNH
Trade = Me!CboTrade
'All reports for Safety Report request
stDocNameSRBF = "SafetyReportbyFM"
stDocNameSRBI = "SafetyReportbyID"
stDocNameSRBN = "SafetyReportbyNH"
stDocNameSRBT = "SafetyReportbyTrade"
'This select the correct report by what cbo field is selected.
If ID = Null And NH = "" And Trade = "" Then
DoCmd.OpenReport stDocNameSRBF, acViewPreview
End If
If FM = "" And NH = "" And Trade = "" Then
DoCmd.OpenReport stDocNameSRBI, acViewPreview
End If
If FM = "" And D = "" And Trade = "" Then
DoCmd.OpenReport stDocNameSRBN, acViewPreview
End If
If FM = "" And ID = "" And NH = "" Then
DoCmd.OpenReport stDocNameSRBT, acViewPreview
End If
If FM = "" And ID = "" And NH = "" And Trade = "" Then
MsgBox "You must select a field to generate a report."
End If
End Sub
determined on what the user selects. However, when I add the combox using
the field Record ID it will not work. When I us all the other option by them
self or as a group they will work. But as soon as I add the Record ID it
will not work. The Record ID is a autonumber field. It is how I save the
records. Can anyone look at the code and see if they have any suggestions.
Private Sub CmdSafety_Click()
Dim stDocNameSRBF As String
Dim stDocNameSRBI As String
Dim stDocNameSRBN As String
Dim stDocNameSRBT As String
FM = Me!CboFM
ID = Me!CboID
NH = Me!CboNH
Trade = Me!CboTrade
'All reports for Safety Report request
stDocNameSRBF = "SafetyReportbyFM"
stDocNameSRBI = "SafetyReportbyID"
stDocNameSRBN = "SafetyReportbyNH"
stDocNameSRBT = "SafetyReportbyTrade"
'This select the correct report by what cbo field is selected.
If ID = Null And NH = "" And Trade = "" Then
DoCmd.OpenReport stDocNameSRBF, acViewPreview
End If
If FM = "" And NH = "" And Trade = "" Then
DoCmd.OpenReport stDocNameSRBI, acViewPreview
End If
If FM = "" And D = "" And Trade = "" Then
DoCmd.OpenReport stDocNameSRBN, acViewPreview
End If
If FM = "" And ID = "" And NH = "" Then
DoCmd.OpenReport stDocNameSRBT, acViewPreview
End If
If FM = "" And ID = "" And NH = "" And Trade = "" Then
MsgBox "You must select a field to generate a report."
End If
End Sub