G
Guest
Hi, I am creating a program in access, but i am using VBA to insert the code.
I have created a program that would not allow a user to enter duplicate
numbers, if the number is duplicate then a msgbox will be displayed, but the
code is not working correctly. I want the code to recognize the difference
between a duplicate account number and a new account number. I have copied a
sample of the code that I have created could someone let me know what am iI
doing wrong or what am I missing in the coding.
Private Sub Account_Number_BeforeUpdate(Cancel As Integer)
Dim strAccount_Number As String, strMsg As String, strDuplicate_Number As
String
Dim strNewAcctNumber As String
If (Account_Number) Or Account_Number = Duplicate_Number Then
strDuplicate_Number = MsgBox("Sorry Duplicate Number, Please Try
Again", vbInformation)
Cancel = True
Else
' If Account Number is not a duplicate number continue process.
If Not Duplicate_Number Then
strNewAcctNumber = MsgBox("Continue", vbInformation)
End If
End If
End Sub
Thank you very much for your help
I have created a program that would not allow a user to enter duplicate
numbers, if the number is duplicate then a msgbox will be displayed, but the
code is not working correctly. I want the code to recognize the difference
between a duplicate account number and a new account number. I have copied a
sample of the code that I have created could someone let me know what am iI
doing wrong or what am I missing in the coding.
Private Sub Account_Number_BeforeUpdate(Cancel As Integer)
Dim strAccount_Number As String, strMsg As String, strDuplicate_Number As
String
Dim strNewAcctNumber As String
If (Account_Number) Or Account_Number = Duplicate_Number Then
strDuplicate_Number = MsgBox("Sorry Duplicate Number, Please Try
Again", vbInformation)
Cancel = True
Else
' If Account Number is not a duplicate number continue process.
If Not Duplicate_Number Then
strNewAcctNumber = MsgBox("Continue", vbInformation)
End If
End If
End Sub
Thank you very much for your help