简体   繁体   中英

SQL Access Criteria Exclusions

I am trying to develop a combobox based on a query. The query excludes a staff member if the date of the appointment is the same as a date they are scheduled to be absent. The statement only runs if it's a particular type of appointment called "Per Session" . So If it's a "perSession" Appointment Query all the staff members who are available on the appointment date. Else Show all staff members.

IIf([Forms]![Scheduling]![ApptType]="PerSession",Not (([Staff].[ABS Date1])=("#" & [Forms]![Scheduling]![EvalDate] & "#")),([Staff].[ABS Date1]) Like "*") Or Is Null

What am I missing here?

In experimentation I found the issue was with the designer. The Designer assumes the Where criteria field in the column will equal the result of the Iif statement. However I was working to not equal if true and equal if not true. By using the SQL view I was able to write the Iif statement to evaluate the proper SQL. See below. (IIf([Forms]![Scheduling]![ApptType]="PerSession",(([Staff].[ABS Date1])<>[Forms]![Scheduling]![EvalDate]) OR ([Staff].[ABS Date1]) Is Null ,([Staff].[ABS Date1]) Like "*" OR ([Staff].[ABS Date1]) Is Null)))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM