Solved

DoCmd Openform WhereCondition Type Mismatch

Posted on 2006-11-04
10
902 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 143

Expert Comment

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

Author Comment

by:ohgee
ID: 17874566
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
ID: 17874573
....correct values were being passed to the &Me statements.
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 65

Expert Comment

by:rockiroads
ID: 17874644
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 17874883
try any of these

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


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


0
 
LVL 65

Expert Comment

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

Expert Comment

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


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

Author Comment

by:ohgee
ID: 17876425
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 75 total points
ID: 17876477
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
ID: 17876609
Thanks; appreciate it
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

828 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