Check duplicate after that file update. (1 Viewer)

Sokkheng

Member
Local time
Today, 15:54
Joined
Jul 12, 2023
Messages
34
I need code for checking Invoice ID after that field is update for protect duplicate. Now my invoice is check duplicate when i click save, so it wast the time for typing.
thanks for reply.
Sokkheng
 

June7

AWF VIP
Local time
Today, 00:54
Joined
Mar 9, 2014
Messages
5,472
You are entering a new record? What would be duplicated - invoice number? Can use domain aggregate function in textbox BeforeUpdate event to check if value already exists in table. Something Like:

If DCount("*", "tablename", "fieldname=" & Me.textboxname) > 0 Then
MsgBox "Invoice number " & Me.textboxname & " already exists."
Cancel = True
Me.textboxName = Null
End If
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:54
Joined
Feb 19, 2013
Messages
16,612
Think you would need to use the .text property for the control before update event
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:54
Joined
Feb 19, 2002
Messages
43,275
Think you would need to use the .text property for the control before update event
No. You only need to use the .text property while you are "in" the control. The BeforeUpdate event of the control runs when you leave the control.

Only use the .text property in the Change event.
 

Users who are viewing this thread

Top Bottom