Searching for a record using a form

G

Guest

I have a form where I input a UPC code (through a bar code scanner). What I want Access to do is to find that particular UPC code in my master inventory table and add a quantity of one to a particular field. If that UPC is not in the master inventory table, I want a dialog box to pop up and say "That item is not available".

I can code the dialog box in the macro, but I can't seem to figure out how to "automate" the search for each UPC code. Thanks.
 
P

PC Datasheet

Cindy,

Your form should be based on your Master Inventory table. I will assume the UPC
field in the table is called UPCCode and you input the UPC code into a textbox
named UPCInput on your form. Put the following code in the AfterUpdate event of
the textbox:
Dim Rst As DAO.Recordset
On Error GoTo ErrorHandler
Set Rst = Me.RecordsetClone
With Rst
.FindFirst "[UPCCode] = '" & Me!UPCInput & "'"
If .NoMatch Then
MsgBox "That Item Is Not Available!"
GoTo ExitHere
End If
Me.BookMark = .BookMark
End With
ExitHere:
Rst.Close
ErrorHandler:
MsgBox Err.Description,,"Error# " & Err.Number
Resume ExitHere


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com




Cindy Nelson said:
I have a form where I input a UPC code (through a bar code scanner). What I
want Access to do is to find that particular UPC code in my master inventory
table and add a quantity of one to a particular field. If that UPC is not in the
master inventory table, I want a dialog box to pop up and say "That item is not
available".
I can code the dialog box in the macro, but I can't seem to figure out how to
"automate" the search for each UPC code. Thanks.
 

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

Top