T
Tim Miller
The code below is working if I only have ONE of my DLookup variants in the
If Then. Either one.
As I have it below, using AND, It allows varExDate to be Not Null and it
works properly, but if varExBranch is Not Null, then it's Type Mismatch
regardless of whether or not varExDate is Null. (varExDate is a Date field
formated as yyyy / mm; varExBranch is a 2 digit text field)
I've tried many renditions of this code. I tried putting an If within If
(If Not IsNull(varExDate) then ... If Not IsNull(varExBranch) then... In
this case I had no response from the code at all. But again, if I only use
one IF (with either variant) then it works perfect.
I'd appreciate any help I could get!!
Dim strDate As String
Dim strBranch As String
Dim Message As Variant
Dim varExDate As Variant
Dim varExBranch As Variant
strDate = [cboYear] & " / " & [cboMonth]
strBranch = [Forms]![Varnet Numbers]![cboBranch]
varExDate = DLookup("[Month]", "Varnet Numbers", "[Month] = #" & strDate &
"#")
varExBranch = DLookup("[Branch]", "Varnet Numbers", "[Branch] = '" &
strBranch & "'")
If Not IsNull(varExDate And varExBranch) Then
Message = MsgBox("An entry for " & strBranch & " already exists for " &
strDate & ". Please check your date, or ask Tim for help in checking the
database for accuracy. This record has not been posted.", 0 + 16,
"Somethings screwed up")
Else
[Forms]![Varnet Numbers]![Month] = strDate
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord acForm, "Varnet Numbers", acNewRec
End If
If Then. Either one.
As I have it below, using AND, It allows varExDate to be Not Null and it
works properly, but if varExBranch is Not Null, then it's Type Mismatch
regardless of whether or not varExDate is Null. (varExDate is a Date field
formated as yyyy / mm; varExBranch is a 2 digit text field)
I've tried many renditions of this code. I tried putting an If within If
(If Not IsNull(varExDate) then ... If Not IsNull(varExBranch) then... In
this case I had no response from the code at all. But again, if I only use
one IF (with either variant) then it works perfect.
I'd appreciate any help I could get!!
Dim strDate As String
Dim strBranch As String
Dim Message As Variant
Dim varExDate As Variant
Dim varExBranch As Variant
strDate = [cboYear] & " / " & [cboMonth]
strBranch = [Forms]![Varnet Numbers]![cboBranch]
varExDate = DLookup("[Month]", "Varnet Numbers", "[Month] = #" & strDate &
"#")
varExBranch = DLookup("[Branch]", "Varnet Numbers", "[Branch] = '" &
strBranch & "'")
If Not IsNull(varExDate And varExBranch) Then
Message = MsgBox("An entry for " & strBranch & " already exists for " &
strDate & ". Please check your date, or ask Tim for help in checking the
database for accuracy. This record has not been posted.", 0 + 16,
"Somethings screwed up")
Else
[Forms]![Varnet Numbers]![Month] = strDate
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord acForm, "Varnet Numbers", acNewRec
End If