I have a table I am running DLOOKUP on to get data. It works as it should, except for when the Criteria is "QUEENS" - it does not pull any data from the table. In VB's immediate window, it does not print any data.
Please see if anything is off in the code. Suggestions welcomed. Thanks.
Please see if anything is off in the code. Suggestions welcomed. Thanks.
Public Function GetDutyStation()
Dim strCity As String
Dim strCounty As String
Dim strState As String
Dim strDSC As String
strCity = Nz(Me.CITY.Value)
strCounty = Nz(Me.cboCOUNTY.Value)
strState = Nz(Me.cboSTATE.Value)
If strCounty <> "" Then
If strCounty = "KINGS" Then
strDSC = Nz(DLookup("[DUTY STATION CODE]", "DUTY STATION CODES", "[COUNTY]=""" & strCounty & """ and [STATE]=""" & strState & """"))
End If
If strCounty = "QUEENS" Then
strDSC = Nz(DLookup("[DUTY STATION CODE]", "DUTY STATION CODES", "[COUNTY]=""" & strCounty & """ and [STATE]=""" & strState & """"))
MsgBox "This is Queens"
End If
If strCounty = "NEW YORK" Then
strDSC = Nz(DLookup("[DUTY STATION CODE]", "DUTY STATION CODES", "[COUNTY]=""" & strCounty & """ and [STATE]=""" & strState & """"))
End If
If strCounty = "RICHMOND" Then
strDSC = Nz(DLookup("[DUTY STATION CODE]", "DUTY STATION CODES", "[COUNTY]=""" & strCounty & """ and [STATE]=""" & strState & """"))
End If
If strCounty = "BRONX" Then
strDSC = Nz(DLookup("[DUTY STATION CODE]", "DUTY STATION CODES", "[COUNTY]=""" & strCounty & """ and [STATE]=""" & strState & """"))
End If
Else
MsgBox "A Duty Station Code was not found. Please lookup duty station code"
Me.txtDutyStationCode.SetFocus
End If
If strCity <> "" Then
If strState <> "" Then
strDSC = Nz(DLookup("[DUTY STATION CODE]", "DUTY STATION CODES", "[CITY]=""" & strCity & """ and [STATE]=""" & strState & """"))
End If
End If
Debug.Print strDSC
Me.txtDutyStationCode.Value = strDSC
End Function