Solved

DoCmd Openform WhereCondition Type Mismatch

Posted on 2006-11-04
10
907 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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 …

730 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