?
Solved

DoCmd Openform WhereCondition Type Mismatch

Posted on 2006-11-04
10
Medium Priority
?
1,017 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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 300 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

650 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