I am having trouble with code that has to be a simple error but I can't determine what it is. I have a form that is linked to a query with one field. I want to evaluate that field and if it is null, perform an action and if it is not null, perform another action. The query and linked field on the form work great. However, the eval form part of my code isn't working properly. It seems to be an If/End If problem that I can't see. No matter whether the form field is null or not it still runs the code as if the field is not null. Following is the code:
Function mcrImportProcess1()
On Error GoTo mcrImportProcess1_Err
Dim Response As Variant
Dim Msg As String
Msg = "Duplicate Invoice and Date! Do you want to Import Anyway?"
'Starts the Check for Dupes here - If frmDupes has data(means that there is a duplicate invoice number already)'
'then jumps to BailOut (ends the function and stops processing)
' If frmDupes does not have data (no duplicate data)then jumps to PROCESS (import data.)
' Opens form in Hidden mode
DoCmd.OpenForm "frmDupes", acFormDS, "", "", acReadOnly, acHidden
If (Eval("[Forms]![frmDupes]![Temporary_InvoiceNum] Is Null")) Then
GoTo Process
Else
Beep
Response = MsgBox(Msg, vbYesNoCancel, "Duplicates")
If Response = vbYes Then
GoTo Process
ElseIf Response = vbNo Then
GoTo BailOut
ElseIf Response = vbCancel Then
GoTo BailOut
End If
BailOut:
DoCmd.Close acForm, "frmDupes"
DoCmd.RunMacro "mcrClosefrmDupe", , ""
End
Process:
DoCmd.OpenQuery "qryStatusC", acNormal, acEdit
DoCmd.OpenQuery "qryErrorCheckCustomerID", acNormal, acEdit
DoCmd.Close acQuery, "qryStatusB"
DoCmd.Close acQuery, "qryStatusA"
DoCmd.SetWarnings True
DoCmd.Close acForm, "frmDupes"
DoCmd.RunMacro "mcrClosefrmDupe", , ""
End If
Exit Function
mcrImportProcess1_Exit:
Exit Function
mcrImportProcess1_Err:
MsgBox Error$
Resume mcrImportProcess1_Exit
End Function
Function mcrImportProcess1()
On Error GoTo mcrImportProcess1_Err
Dim Response As Variant
Dim Msg As String
Msg = "Duplicate Invoice and Date! Do you want to Import Anyway?"
'Starts the Check for Dupes here - If frmDupes has data(means that there is a duplicate invoice number already)'
'then jumps to BailOut (ends the function and stops processing)
' If frmDupes does not have data (no duplicate data)then jumps to PROCESS (import data.)
' Opens form in Hidden mode
DoCmd.OpenForm "frmDupes", acFormDS, "", "", acReadOnly, acHidden
If (Eval("[Forms]![frmDupes]![Temporary_InvoiceNum] Is Null")) Then
GoTo Process
Else
Beep
Response = MsgBox(Msg, vbYesNoCancel, "Duplicates")
If Response = vbYes Then
GoTo Process
ElseIf Response = vbNo Then
GoTo BailOut
ElseIf Response = vbCancel Then
GoTo BailOut
End If
BailOut:
DoCmd.Close acForm, "frmDupes"
DoCmd.RunMacro "mcrClosefrmDupe", , ""
End
Process:
DoCmd.OpenQuery "qryStatusC", acNormal, acEdit
DoCmd.OpenQuery "qryErrorCheckCustomerID", acNormal, acEdit
DoCmd.Close acQuery, "qryStatusB"
DoCmd.Close acQuery, "qryStatusA"
DoCmd.SetWarnings True
DoCmd.Close acForm, "frmDupes"
DoCmd.RunMacro "mcrClosefrmDupe", , ""
End If
Exit Function
mcrImportProcess1_Exit:
Exit Function
mcrImportProcess1_Err:
MsgBox Error$
Resume mcrImportProcess1_Exit
End Function