Using AND and OR in same linkcriteria

  • Thread starter scottyb121 via AccessMonster.com
  • Start date
S

scottyb121 via AccessMonster.com

I am trying to run a report with the criteria: a AND (b OR c). Here is the
code I am trying to use but it keeps coming out as (a AND b) OR c. I am
trying to figure out how and where to put " or () but I keep getting errors
when I think I have it right.


stLinkCriteria = "[DOS]=" & Chr(34) & Me.DateScheduled & Chr(34)

stLinkCriteria = stLinkCriteria & " AND [PatientRecordID]=" & Me.
PatientRecordID & " OR [PatientName]= " & Chr(34) & Me.PatientName & Chr(34)
 
S

scottyb121 via AccessMonster.com

That did it! Thank you so much Roger. I had the right idea but I just kept
forgetting to put that last " at the end so I kept getting an error message.

Roger said:
Well, I'd do it like this:

stLinkCriteria = "[DOS]=""" & Me.DateScheduled & """"
stLinkCriteria = stLinkCriteria & " AND ([PatientRecordID]=" & Me.
PatientRecordID & " OR [PatientName]= """ & Me.PatientName & """)"

Which (I think) would translate to:

stLinkCriteria = "[DOS]=" & Chr(34) & Me.DateScheduled & Chr(34)
stLinkCriteria = stLinkCriteria & " AND ([PatientRecordID]=" & Me.
PatientRecordID & " OR [PatientName]= " & Chr(34) & Me.PatientName & Chr(34)
&")"
I am trying to run a report with the criteria: a AND (b OR c). Here is the
code I am trying to use but it keeps coming out as (a AND b) OR c. I am
[quoted text clipped - 7 lines]
PatientRecordID & " OR [PatientName]= " & Chr(34) & Me.PatientName &
Chr(34)
 
R

Roger Carlson

You're welcome. Glad it worked.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


scottyb121 via AccessMonster.com said:
That did it! Thank you so much Roger. I had the right idea but I just
kept
forgetting to put that last " at the end so I kept getting an error
message.

Roger said:
Well, I'd do it like this:

stLinkCriteria = "[DOS]=""" & Me.DateScheduled & """"
stLinkCriteria = stLinkCriteria & " AND ([PatientRecordID]=" & Me.
PatientRecordID & " OR [PatientName]= """ & Me.PatientName & """)"

Which (I think) would translate to:

stLinkCriteria = "[DOS]=" & Chr(34) & Me.DateScheduled & Chr(34)
stLinkCriteria = stLinkCriteria & " AND ([PatientRecordID]=" & Me.
PatientRecordID & " OR [PatientName]= " & Chr(34) & Me.PatientName &
Chr(34)
&")"
I am trying to run a report with the criteria: a AND (b OR c). Here is
the
code I am trying to use but it keeps coming out as (a AND b) OR c. I am
[quoted text clipped - 7 lines]
PatientRecordID & " OR [PatientName]= " & Chr(34) & Me.PatientName &
Chr(34)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top