A
Aad via AccessMonster.com
Hi,
For my ADP I need to show a (alert) message box when a user tries to add a
reference number (field: reject_ref) which already exist in de db.
In other words the entry for this field must be unique otherwise the user
must be informed about it by means of the message box.
My code so far (adapting from similar threat):
Private Sub reject_ref_Exit(Cancel As Integer)
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("SELECT * FROM [reject] WHERE [reject].
[reject_ref]='" & Me![reject_ref].Value & "';")
If Not rs.EOF Then
MsgBox "The reference number you entered already exists. Please enter
a unique value"
Cancel = True
Me![reject_ref].Value = Null
Me![reject_ref].SetFocus
End If
rs.Close
End Sub
However it’s not working. (Object variable not set etc…)
Can someone please help with this?
Very thanks,
Aad
For my ADP I need to show a (alert) message box when a user tries to add a
reference number (field: reject_ref) which already exist in de db.
In other words the entry for this field must be unique otherwise the user
must be informed about it by means of the message box.
My code so far (adapting from similar threat):
Private Sub reject_ref_Exit(Cancel As Integer)
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("SELECT * FROM [reject] WHERE [reject].
[reject_ref]='" & Me![reject_ref].Value & "';")
If Not rs.EOF Then
MsgBox "The reference number you entered already exists. Please enter
a unique value"
Cancel = True
Me![reject_ref].Value = Null
Me![reject_ref].SetFocus
End If
rs.Close
End Sub
However it’s not working. (Object variable not set etc…)
Can someone please help with this?
Very thanks,
Aad