mytaurus2000
Technical User
IWhen entering my form, a user types in customer id. If customer exists a message box tells user can't add record because id exists. If customer id exists, I would like the fields to automatically populate with the entered id.
Private Sub SSN_BeforeUpdate(Cancel As Integer)
Dim rstNewApp As New ADODB.Recordset
Dim x As Variant
x = DLookup("[SSN]", "tblApplicantInformation", "[SSN]='" _
& Forms!frmApplicantDataEntry!SSN & "'")
On Error GoTo SSN_Err
If Not IsNull(x) Then
Beep
MsgBox "That SSN already exist in this database. Please look it up.", vbCritical, _
"Duplicate Value"
Cancel = True
End If
SSN_Exit:
Exit Sub
SSN_Err:
MsgBox Error$
Resume SSN_Exit
End Sub
How can I edit code to populate fields with current record?
Private Sub SSN_BeforeUpdate(Cancel As Integer)
Dim rstNewApp As New ADODB.Recordset
Dim x As Variant
x = DLookup("[SSN]", "tblApplicantInformation", "[SSN]='" _
& Forms!frmApplicantDataEntry!SSN & "'")
On Error GoTo SSN_Err
If Not IsNull(x) Then
Beep
MsgBox "That SSN already exist in this database. Please look it up.", vbCritical, _
"Duplicate Value"
Cancel = True
End If
SSN_Exit:
Exit Sub
SSN_Err:
MsgBox Error$
Resume SSN_Exit
End Sub
How can I edit code to populate fields with current record?