?
Solved

DoCmd Openform WhereCondition Type Mismatch

Posted on 2006-11-04
10
Medium Priority
?
970 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

800 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