473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Could I get some help with a string DLookup?

5
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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub WO_AfterUpdate()
  2.     Dim stDate As Date
  3.     Dim stCust As String
  4.     Dim stOrd As String
  5.     Dim stItem As String
  6.     Dim stQty As Integer
  7.     Dim stPL As String
  8.     Dim ststdum As String
  9.     Dim ststdprice As String
  10.     Dim ststdcost As String
  11.  
  12.     stDate = DLookup("[WODate]", "[WO table]", "[WO]=[woid]")
  13.     stCust = DLookup("[Customer]", "[WO table]", "[WO]=[woid]") & " "
  14.     stOrd = DLookup("[salesord]", "[WO table]", "[WO]=[woid]") & " "
  15.     stItem = DLookup("[itemno]", "[WO table]", "[WO]=[woid]")
  16.     stQty = DLookup("[qty]-nz([scrapqty])", "[WO table]", "[WO]=[woid]")
  17.  
  18.  
  19.     [Forms]![wo complete]![1Date] = stDate
  20.     [Forms]![wo complete]![2Cust] = stCust
  21.     [Forms]![wo complete]![3Ord] = stOrd
  22.     [Forms]![wo complete]![4Item] = stItem
  23.     [Forms]![wo complete]![5Qty] = stQty
  24.     stPL = DLookup("[ProductLine]", "[IM1_InventoryMasterfile]", "[ItemNumber] = 'Forms![wo complete]![4Item]'")
  25.     ststdum = DLookup("[StdUM]", "[IM1_InventoryMasterfile]", "[ItemNumber] = ""TEST""")
  26.     ststdprice = DLookup("[StdPrice]", "[IM1_InventoryMasterfile]", "[ItemNumber] = ""TEST""")
  27.     ststdcost = DLookup("[StdCost]", "[IM1_InventoryMasterfile]", "[ItemNumber] = ""TEST""")
  28.     [Forms]![wo complete]![ProductLine] = stPL
  29.     [Forms]![wo complete]![StdUM] = ststdum
  30.     [Forms]![wo complete]![StdPrice] = ststdprice
  31.     [Forms]![wo complete]![StdCost] = ststdcost
  32.  
  33.  
  34. End Sub
  35.  
Thank you for your consideration and help.
Jan 6 '11 #1
8 2361
Rabbit
12,516 Expert Mod 8TB
'Forms![wo complete]1[4Item]'

You have a 1 in there instead of a !.
Jan 6 '11 #2
JDaly
5
I changed it in the code and it still doesn't work, and edited the post to reflect the change.
Thank you for looking through the code and taking the time to help. I have been beating my head against a wall and retyping this with different syntaxes for some time.
Jan 6 '11 #3
Rabbit
12,516 Expert Mod 8TB
Remove the single quotes.
Jan 6 '11 #4
JDaly
5
Removed the single quotes. Still gives a null error.
Thanks again.
I wounder if IM1_InventoryMasterfile being a linked file which is read only is affecting this? It evaluates correctly when I substitute in the ""TEST"" and reads the test data but doesn't seem to work with any of the standard string methods even though it evaluates in Ctrl-g as ? [Forms]![wo complete]![4Item] being equal to TEST.
Jan 6 '11 #5
Rabbit
12,516 Expert Mod 8TB
What's the full text of the error message? If you're getting a message on null, Try the Nz function.
Jan 6 '11 #6
JDaly
5
Run time error '94':
Invalid use of null
And that error message was after I changes the [Forms]![wo complete]![4Item] to Nz([fORMS]![wo complete]![4Item])

In immediate mode ? Nz[4Item]
evaluates to test as it should but doesn't in the expression.
Jan 6 '11 #7
Rabbit
12,516 Expert Mod 8TB
Well, you need to specify what to use instead of Null. Use, Nz([fORMS]![wo complete]![4Item], "")
Jan 6 '11 #8
JDaly
5
I tries somethink that worked. I still don't understand why it worked but I changed the line to
stPL = DLookup("[ProductLine]", "[IM1_InventoryMasterfile]", "[ItemNumber] = [4Item]") & Mid(stItem, 1, 0)
It may be kludgy, and I haven't checked to see what kind of performance hit it gives but for the time being I can move along. Thank you for all the help. I was stuck in a rut and really needed some new ideas on how to approach the problem. It seems to be an odd way to force the criterion into a string mode where all the text book answers didn't work. I really appreciate the feed back and your time. This is one of the wierdest problems I have seen in a while.
Jan 6 '11 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Norman Fritag | last post by:
Hi there, I am wonder why this dlookups return null, despite having a record in the table with a matching date? Am I missing something here??? Am i running in some limitations, that I am not...
4
by: basstwo | last post by:
I have a field with a serial number in it. I want to use Mid to extract the 4th and 5th characters, use them to lookup a value on a small lookup table, and use the info from that table to fill in...
6
by: Don Sealer | last post by:
I've written this expression for a DLookup function. It works almost alright. What I'm trying to do is type in a description and the ID field (number) populates automatically. It works almost as...
2
by: Don | last post by:
Can someone help me fix my DLookup problem. I'm far from proficiency with Access. I've been creating databases for several years for work with the help of many of you and trial and error. I have...
21
by: Thelma Lubkin | last post by:
I would like my DLookup criteria to say this: Trim(fieldX) = strVar: myVar = _ DLookup("someField", "someTable", "Trim(fieldX) = '" & strVar & '") I don't believe that this will work, and I...
2
Loismustdie129
by: Loismustdie129 | last post by:
I don't really know if this is right to ask this here or not (and if it isn't please correct me) but I was wondering if you guys could help me learn about databases and MySQL. I have googled this...
2
by: db2 | last post by:
Hi, I have heard that stored procedure on Z/OS can be written on assembler language only. Can any body could help me out on DB2 stored procedure on Z/OS. If you recommend me any materials, that...
0
by: moon22 | last post by:
Hi every one... I have a project that takes data from a ZigBee wireless microcontroller (the code is written in C) and safe the data into a file through a ConnectPort X Gateway that support...
4
by: QC | last post by:
Hi Friends, I have one Application running on Client PC, i coded to store all Debug, Info, and Trace related information in Log file. This log file helps me to analyze the exception if any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.