?
Solved

Access 2010 Where Condition on a DoCmd OpenForm

Posted on 2014-10-29
5
Medium Priority
?
227 Views
Last Modified: 2014-10-29
I need to combined these together and separated with OR for a WHERE CONDITION on a DoCmd OpenForm.

'2
    stLinkCriteria2 = "[RoutedTo] like '???/" & txtCategoryList & "*'"
    stLinkCriteria2a = stLinkCriteria2 & " And [AllItemCal2] is Null"
'3
    stLinkCriteria3 = "[RoutedTo] like '???/???/" & txtCategoryList & "*'"
    stLinkCriteria3a = stLinkCriteria3 & " And [AllItemCal3] is Null"
'4
    stLinkCriteria4 = "[RoutedTo] like '???/???/???/" & txtCategoryList & "*'"
    stLinkCriteria4a = stLinkCriteria4 & " And [AllItemCal4] is Null"

In other words, I should end up with something like...

stLinkCriteria = stLinkCriteria2a OR stLinkCriteria3a OR stLinkCriteria4a

Can someone help me with the syntax.

Thanks in advance!
0
Comment
Question by:Senniger1
[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
  • 2
  • 2
5 Comments
 
LVL 48

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 40410515
you are going to need to wrap your individual critieria in () .

stLinkCriteria2a = "(" & stLinkCriteria2 & " And [AllItemCal2] is Null)"
stLinkCriteria3a = "(" & stLinkCriteria3 & " And [AllItemCal3] is Null)"
stLinkCriteria4a = "(" & stLinkCriteria4 & " And [AllItemCal4] is Null)"

Then, your syntax of :

stLinkCriteria = stLinkCriteria2a OR stLinkCriteria3a OR stLinkCriteria4a

should work
0
 

Author Comment

by:Senniger1
ID: 40410536
I'm getting a Run-time error 13:  type mismatch.

Shouldn't the following line be formatted some way as well?
stLinkCriteria = stLinkCriteria2a OR stLinkCriteria3a OR stLinkCriteria4a

Thanks!
0
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 40410548
pls try

stLinkCriteria = stLinkCriteria2a & " OR  " & stLinkCriteria3a & " OR  " & stLinkCriteria4a
0
 

Author Closing Comment

by:Senniger1
ID: 40410561
Perfect!
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 40410564
Yes, like Rgonzo says.
0

Featured Post

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.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

770 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