Solved

DoCmd Openform WhereCondition Type Mismatch

Posted on 2006-11-04
10
861 Views
Last Modified: 2008-02-01
Hi
Have some code that looks like this but returns type mistype error.

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "ChooseAuditReadOnly"
stLinkCriteria = "[AuditNumber]= " & Me![AuditNumber] And "[Auditor] = " & Me![Auditor]

If I take out the "And" clause it works fine; so there is some problem with
And "[Auditor] = " & Me![Auditor]

The data types are matched so not sure what the problem is.
Thank you
0
Comment
Question by:ohgee
  • 4
  • 2
  • 2
  • +1
10 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
the AND needs to be part of the string:
stLinkCriteria = "[AuditNumber]= " & Me![AuditNumber]  " And [Auditor] = " & Me![Auditor]
0
 

Author Comment

by:ohgee
Comment Utility
Thanks, tried this but now get compile error: expected end of statement. When I had the And outside of the string seems that correct values being being passed to the &Me statements.
0
 

Author Comment

by:ohgee
Comment Utility
....correct values were being passed to the &Me statements.
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
Is Auditor a String field? does it contain text? you did say data types match, but is that on table level?


stLinkCriteria = "[AuditNumber]= " & Me![AuditNumber] And "[Auditor] = '" & Me![Auditor] & "'"


0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
try any of these

stLinkCriteria = "[AuditNumber]= " & Me![AuditNumber] &" And [Auditor] = " & Me![Auditor]


stLinkCriteria = "[AuditNumber]= " & Me![AuditNumber] &" And [Auditor] = '" & Me![Auditor] & "'"


0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
noticed a typo in my post, a rogue double quote before [Auditor] =
get rid of that
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
I see that I forgot the & , like capricorn1 posted:


stLinkCriteria = "[AuditNumber]= " & Me![AuditNumber] & " And [Auditor] = " & Me![Auditor]
0
 

Author Comment

by:ohgee
Comment Utility
Thanks very much for the help.

The only one that seems to work is
stLinkCriteria = "[AuditNumber]= " & Me![AuditNumber] &" And [Auditor] = '" & Me![Auditor] & "'"

Ma finding it difficult to get good written guidance on how to use quotes, wher eto place them etc. Are you aware of any good online reading sources.
Thanks again.
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 75 total points
Comment Utility
if field type of data is

number  use  "    like this  "[AuditNumber]= " & Me![AuditNumber]

text  add a single quote  like this    "[Auditor] = ' " & Me![Auditor] & " ' "
                                                                ---^ single quote -------^  
0
 

Author Comment

by:ohgee
Comment Utility
Thanks; appreciate it
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now