Combining "and" and "or"

MarionD

Registered User.
Local time
Today, 17:34
Joined
Oct 10, 2000
Messages
425
Hi all,

I am having a problem opening a form and displaying certain LinkCriteria. I need to combine and and/or clause.

I need to select all records where the patient Nr is the same (me.patnr) and the category is either "P" or "S"

I've tried different variations but cannot get it to select the correct records!

stLinkCriteria = ("[KT]='P'" and "[PatNr]=" & Me.[PatNr]) & " Or " & ("[KT]='S'" and "[PatNr]=" & Me.[PatNr])

Help much appreciated!
 
Try:
stLinkCriteria = "([KT]='P' OR [KT]='S') AND [PatNr]=" & Me.[PatNr]

From your post I've assume [Patnr] is a numeric data type (not text).

I often find doing the followng in the code helps see how the string really looks. The value of stLinkCriteria will show in the intermediate window:

debug.print stLinkCriteria

hth
Stopher
 
Try:
stLinkCriteria = "[PatNr]= " & Me.PatNr & " AND ([KT]= 'S' OR [KT] = 'P')"
if PatNr is numeric otherwise it will need to be surrounded with single quotes.
 

Users who are viewing this thread

Back
Top Bottom