This bombs on the StPL= line. I want it to look up a string value from a table with a criterion of matching another string. In immediate mode the form evaluates correctly with ? Form![wo complete]![4Item] as TEST but it returns a null in when executed. I have tinkered with syntax for way too long and would like to get past this part of a project. The lines with """"TEST"" all return a value stored under TEST in the file.
Thank you for your consideration and help.
Code:
Private Sub WO_AfterUpdate() Dim stDate As Date Dim stCust As String Dim stOrd As String Dim stItem As String Dim stQty As Integer Dim stPL As String Dim ststdum As String Dim ststdprice As String Dim ststdcost As String stDate = DLookup("[WODate]", "[WO table]", "[WO]=[woid]") stCust = DLookup("[Customer]", "[WO table]", "[WO]=[woid]") & " " stOrd = DLookup("[salesord]", "[WO table]", "[WO]=[woid]") & " " stItem = DLookup("[itemno]", "[WO table]", "[WO]=[woid]") stQty = DLookup("[qty]-nz([scrapqty])", "[WO table]", "[WO]=[woid]") [Forms]![wo complete]![1Date] = stDate [Forms]![wo complete]![2Cust] = stCust [Forms]![wo complete]![3Ord] = stOrd [Forms]![wo complete]![4Item] = stItem [Forms]![wo complete]![5Qty] = stQty stPL = DLookup("[ProductLine]", "[IM1_InventoryMasterfile]", "[ItemNumber] = 'Forms![wo complete]![4Item]'") ststdum = DLookup("[StdUM]", "[IM1_InventoryMasterfile]", "[ItemNumber] = ""TEST""") ststdprice = DLookup("[StdPrice]", "[IM1_InventoryMasterfile]", "[ItemNumber] = ""TEST""") ststdcost = DLookup("[StdCost]", "[IM1_InventoryMasterfile]", "[ItemNumber] = ""TEST""") [Forms]![wo complete]![ProductLine] = stPL [Forms]![wo complete]![StdUM] = ststdum [Forms]![wo complete]![StdPrice] = ststdprice [Forms]![wo complete]![StdCost] = ststdcost End Sub
Comment