FindRecord from after scan

  • Thread starter Thread starter Anthony
  • Start date Start date
A

Anthony

Hi,

I'm trying to create a txt-field that looks up a value in my producttable.
The field is called "EAN" and is a unique field.
Now normally this would watch over the input of duplicat values and is
does that but , When i add a new record, the EAN field comes first and then
about 14 other fields to enter. Now Access lets me know when a Duplicate
Value
is entered by telling me "Cannot add record, it would create duplicate
values in ...."
But it tells me that after enter al 15 textfields, Is there a way to check
for these
duplicate values after entering data in the EAN-field? Lets say on the event
"Before-Update"
I have been trying such with "FindFirst" and Do-While but i'm not that
great programmer
to get that work out just right.

So in short, i would like to find the record in my product-table after i
entered data in my EAN-field.
Anybody any suggestions, any code, are very much appreciated,

Thanks In Adavance

Anthony
 
Use the AfterUpdate event procedure of the text box, to provide the warning
as soon as the user enters it.

Private Sub EAN_AfterUpdate()
Dim strWhere As String
With Me.EAN
If IsNull(.Value) Or (.Value = .OldValue) Then
'do nothing
Else
strWhere = "EAN = " & .Value
If Not IsNull(DLookup("EAN", "Table1", strWhere)) Then
MsgBox "Duplicate!"
End If
End If
End With
End Sub

If you need further help with DLookup(), see:
http://members.iinet.net.au/~allenbrowne/casu-07.html
 
Thanks, Works great,

Is it also possible to go to the record that was entered in the EAN-Field??

Thanks in advance,

Anthony
 
To do that, you would need to undo the form (i.e. Me.Undo), and then
FindFirst in the RecordsetClone of the form, and match bookmarks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top