Hello Everyone,
I am probably doing something wrong or have something in the wrong place. I am trying to a DLookup to see if a duplicate number already exists and if it is in the open status. The table name is settlements, the text field is called txtloan1, the columns in the database are loan1 and status. The status field is where it will check for the open status. Below is the code:
<code>
Private Sub txtloan1_AfterUpdate()
If IsNull(DLookup("[loan1]", "settlement", "[loan1] = " & Me.txtloan1.Text & " AND [status] = 'Open'")) = False Then
Cancel = True
MsgBox "Loan Number already exists and is in open status", vbOKOnly, "Warning"
End If
End Sub
</code>
I have it triggered using the after update event within the text field property box. I do not want the user to fill out the form completely just to have it come back as a duplicate error.
Thanks!!
I am probably doing something wrong or have something in the wrong place. I am trying to a DLookup to see if a duplicate number already exists and if it is in the open status. The table name is settlements, the text field is called txtloan1, the columns in the database are loan1 and status. The status field is where it will check for the open status. Below is the code:
<code>
Private Sub txtloan1_AfterUpdate()
If IsNull(DLookup("[loan1]", "settlement", "[loan1] = " & Me.txtloan1.Text & " AND [status] = 'Open'")) = False Then
Cancel = True
MsgBox "Loan Number already exists and is in open status", vbOKOnly, "Warning"
End If
End Sub
</code>
I have it triggered using the after update event within the text field property box. I do not want the user to fill out the form completely just to have it come back as a duplicate error.
Thanks!!