Weird problem with updating a record

woknick

Registered User.
Local time
Today, 02:20
Joined
Sep 25, 2004
Messages
85
The Problem Im having is that when I enter a value in the txtBarcode, Access adds that barcode to the table BarcodeList before I get a chance to search for the barcode.

I want to be able to take the number entered in the text box and check the table first before updating the record

Whats happing now is that when I press enter on the form access saves the current value and then searches for the value it just entered. Of course it is going to find it because it just added it.


Private Sub txtBarcode_Exit(Cancel As Integer)

Dim varX As Variant
Cancel = True
varX = DLookup("[Barcode Number]", "BarcodeList", "[Barcode Number] = '" _
& txtBarcode.Text & "'")
If IsNull(varX) Then

'add record
Else

txtTest.Value = txtTest
txtBarcode.Value = " "
txtBarcode.SetFocus
DoCmd.OpenForm ("WARNING")


PLEASE HELP

THANKS NICK
 
Have you tried using the before update event?


???
kh
 
Yes I have, and it does not work
 
Actually the beforeUpdate did work. Thanks for the help
 
In the before update event:

if not Isnull(DLookup("[Barcode Number]", "BarcodeList", "[Barcode Number] = '" & txtBarcode.Text & "'")) then

DoCmd.CancelEvent

end if

???
kh

edit: Cool...
 

Users who are viewing this thread

Back
Top Bottom