Autofill in forms confusion

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, I'm a little confused;

If I have a form, which has a textbox called "Barcode" and another textbox
called "Product Description", then I have a table called "Product
Information Data" which has two fields, one called "Product Barcode" and
another called "Product Description":-

How do I force the form to automatically look up "Product Description" from
the "Product Information Data" dependent on what the user typed in the
"Barcode" textbox on the form?

I figure it's a basic SELECT query, but I'm damned if I know how...
 
It would be easiler to use a combo box to do this. There is even a wizard to
write the code for you.

Using a textbox, you can use the AfterUpdate event to either use the DLookup
function, or build a recordset, something like (aircode):

Assuming that the Barcode field is numeric

Sub Barcode_AfterUpdate()

Dim intSearch As Integer
Dim X As Variant
intSearch = Me.Barcode

X = DLookup("[Product Description]", "[Product Information Data]", _
"[Product Barcode] = " & intSearch)

Me.[Product Description] = X

End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top