Searching for a record using a form

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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.
 
Back
Top