Hi there
I have undertaken the adventure of building a database for my company to log test results of raw materials.
I have set up the tables and forms and everything is working perfectly. The only problem I have is the following.
I want a popup message to appear when a batch number is duplicated, so no duplicate batch entries are logged.
The problem is, even though a batch number is NOT duplicated, the message pops up regardless, and the entry is cancelled.
What I need to happen is that, if the number is not duplicated, the record must be entered as if there were no conditions.
Here is the code I used. I got it from another forum from 2003(?)
Private Sub Batch_Number_BeforeUpdate(Cancel As Integer)
If DCount("[Batch_Number]", "tblBatches", "[Batch_Number]='" & Me.Batch_Number & "'") Then
MsgBox "This batch number has already been logged!" & _
vbCrLf & "For Re-Assays, add suffix RE1 or RE2, as necessary.", vbOKOnly, "Duplicated entry"
Cancel = True
Me.Undo
Exit Sub
Else 'Do nothing
End If
End Sub
Thanks in advance!
Brenda