Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dlookup problem with sub form

Status
Not open for further replies.

k8277

Programmer
Jan 10, 2003
104
US
I have three tables: 1. tblParts, 2. tblOrders, 3. tblOrderDetails.

The tables have the following fields:

tblParts: PartNum, Pcs per Box
tblOrders: OrderNumber
tblOrderDetails: OrderNumber, Order Detail Id, PartNumber, Quantity, NumberOfBoxes

tblOrderDetails is a sub form on tblOrders

The problem I am having is that after I select my PartNumber on the OrderDetails sub form, the Dlookup function returns a null value and my NumberOfBoxes does not get updated.

Here is my code from the OrderDetails Form:

Private Sub Part_Number_AfterUpdate()

Dim piecesperbox As Variant

piecesperbox = DLookup("[Pcs per Box]", "tblParts", "[PartNum]=" & Me!PartNumber)
Me!NumberOfBoxes = piecesperbox / Me!Quantity

End Sub
 
Hi,

a)Is PartNumber on your subform?
b)Where does 'piecesperbox' come from?

Regards,

Darrylle

"Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
Yes PartNumber is in the subform and piecesperbox comes from tblParts.

I think I got this working, I had to add a single quote in the criteria around Me!PartNumber.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top