Solved

Access 2010 Where Condition on a DoCmd OpenForm

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

17 Experts available now in Live!

Get 1:1 Help Now