Solved

Access 2010 Where Condition on a DoCmd OpenForm

Posted on 2014-10-29
5
221 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
  • 2
  • 2
5 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 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 49

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 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40410564
Yes, like Rgonzo says.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

809 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