473,409 Members | 1,985 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,409 software developers and data experts.

Help in dmax using 2 criterias

82 64KB
please can you check my code below it returns an error: TYPE MISMATCH

moveCtr is a variable string
fields in table: assetNo and moveCode

Expand|Select|Wrap|Line Numbers
  1. tstJobCode = Nz(DMax("toJobcode", "assetMovementTable", "assetNo LIKE '" & Me.txtAssetNo & "*'" And "moveCode LIKE '" & moveCtr & "*'"), "")
Apr 16 '13 #1

✓ answered by Seth Schrock

The word AND in your criteria needs to be inside the quotes.
Expand|Select|Wrap|Line Numbers
  1. tstJobCode = Nz(DMax("toJobcode", "assetMovementTable", "assetNo LIKE '" & Me.txtAssetNo & "*' And moveCode LIKE '" & moveCtr & "*'"), "")

4 1270
Seth Schrock
2,965 Expert 2GB
The word AND in your criteria needs to be inside the quotes.
Expand|Select|Wrap|Line Numbers
  1. tstJobCode = Nz(DMax("toJobcode", "assetMovementTable", "assetNo LIKE '" & Me.txtAssetNo & "*' And moveCode LIKE '" & moveCtr & "*'"), "")
Apr 16 '13 #2
zmbd
5,501 Expert Mod 4TB
Well, then something has been declaried a different datatype than what you expected.

First: What is the datatype for "tstJobCode"
Second: What does your criteria string resolve to... you'll need to modify the code a tad to trouble shoot the resolved string. This is always the issue when the criteria is built "in-line" with the function because it makes it very deficult to determine what the string resolves to... This is one of my petpeeves

I have not altered your code persay... however this is what I'd suggest you do:

(caution... this is basically air code so you can see what I'm suggesting you do to troubleshoot your code.)
Expand|Select|Wrap|Line Numbers
  1. Sub zxmple()
  2. Dim tstJobCode As String
  3. Dim strSQL As String
  4. '
  5. 'Setup the criteria string as a seperate string:
  6. strSQL = "assetNo LIKE '" & Me.txtAssetNo & "*'" And "moveCode LIKE '" & moveCtr & "*'"
  7. '
  8. 'Now you can debug the string... to see it press <ctrl><g>
  9. Debug.Print strSQL
  10. '
  11. '>>>insert a STOP so you can review the string
  12. Stop
  13. '
  14. 'and now here we go.... I suspect that if you did define the tstJobCode as a string then the "" is the error
  15. 'i'll just stick a zero in there for now.
  16. tstJobCode = Nz(DMax("toJobcode", "assetMovementTable", strSQL), "0")
  17. '
  18. End Sub
  19.  
Apr 16 '13 #3
deanvilar
82 64KB
that solves it wheeew ... thank you again sir Seth!!!
Apr 16 '13 #4
deanvilar
82 64KB
thank you for the suggestion sir ZMBD, what sir seth did already worked .. thank you very much!
Apr 16 '13 #5

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

Similar topics

4
by: engrkhalid | last post by:
Hello everybody, When I send an email to any Hotmail account it goes directory to the Junk Email! My website is in a dedicated server using: Linux 2.4.21, Apa­che, PHP, MySQL I'm using the...
0
by: serge calderara | last post by:
Dear all, In my application I ma using a small windows form wich is displayed information based on a ertain criteria. That forms gets display in Messenger notofication style. For that I am using...
6
by: Charlie | last post by:
Dear all, I am stuck on this problem, couldn't find an answer on any C++ book in the bookshop. Following is a cut of my program, and its error message:...
3
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With...
5
by: ggk517 | last post by:
We are trying to develop an Engineering application using PHP, Javascript with Informix as the back-end. Is it possible to retrieve data using Javascript but by accessing the Database. Say...
3
by: yinglcs | last post by:
Hi, I am trying to setup Apache with Trac which uses mod_python. I get the following error: assert have_pysqlite 0 And I have verify this via command line as well, that seem no problem....
1
by: lnong | last post by:
Im using the ActivePDF Toolkit to programmatically fill in a PDF document using .NET. I have a mulitline textfield (textbox), and I want to be able to insert a newline character. I cannot find a...
1
by: vbsoft | last post by:
Hello My Name is Mike Am from Nigeria a student of computer Science, Pls i want your You to help in Using VISUAL BASIC 6.0 AND MS SQL SERVER AS DATABASE AS A CLIENT SERVER SIDE pLS: I...
2
by: Alexnb | last post by:
Okay, I am not sure if there is a better way of doing this than findAll() but that is how I am doing it right now. I am making an app that screen scapes dictionary.com for definitions. However, I...
3
sweetzhay
by: sweetzhay | last post by:
i already know how to get the output of 1 12 123 1234 12345 using while wend and now my problem is to show the output of 1 21
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.