How to auto fill info. from a table to a form?

F

Frank Stone

here is a sub i used to auto fill 2 other text boxes when
some enter a PO in the PO txtbox. has quallifiers too.
Maybe you can use it as a template or maybe get some ideas.
delete all of my field names and tables and add in yours.
It uses the dLookup function. syntax:
dlookup("[field1]","table","[field2]='" & me.control & "'"

Private Sub txtPOonPackSlip_BeforeUpdate(Cancel As Integer)
Dim txtPOonPackSlip As Variant

If (IsNull(DLookup
("[POI_Reference]", "POI", "[POI_PurchOrderID]='" & Me!
txtPOonPackSlip & "' and [POI_Reference] = '" & Me!
txtItemID & "'"))) Then
MsgBox ("The ItemID entered is not on the PO
entered. Check your Input.")
Exit Sub
Else
Me!txtVendorName = DLookup
("[POM_PayName]", "POM", "[POM_PurchOrderID] ='" & Me!
txtPOonPackSlip & "'")
Me!txtBuyer = DLookup
("[POM_Buyer]", "POM", "[POM_PurchOrderID] = '" & Me!
txtPOonPackSlip & "'")
End If
End Sub
 

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