Solved

Access 2010 Where Condition on a DoCmd OpenForm

Posted on 2014-10-29
5
218 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

919 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now