Query using IIF and Like (1 Viewer)

jayrolando

New member
Local time
Yesterday, 21:54
Joined
Mar 25, 2020
Messages
4
New to Access and have been practicing using old assignments I've found online. Enjoying the functionality of it all but now I've hit a roadblock.

The instructions are the following:
Create a query using the tblCustomer table. Display CustomerID, FirstName, LastName, and a new calculated field named Coupon?, in that order. In the Coupon? field, use the IIf and Like functions to display No Coupon if the customer did not take the tour and Send 10% off next visit if the customer did take the tour.
Tours being recorded as checked boxes in the tblCustomer table.

Up until now I've been using IIF and Like separately and I am now stumped as to how to use them together.

Any help would be greatly appreciated.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 18:54
Joined
Aug 30, 2003
Messages
36,125
Along the lines of:

IIf(Something Like "*Blah*", True, False)
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:54
Joined
Oct 29, 2018
Messages
21,467
Hi Jay. Welcome to AWF!
 

jayrolando

New member
Local time
Yesterday, 21:54
Joined
Mar 25, 2020
Messages
4
Along the lines of:

IIf(Something Like "*Blah*", True, False)

Maybe I'm just overthinking it or not doing it right but whenever I try something like that, I'll end up with checkboxes or warning dialog boxes, instead of the intended display output.
 

isladogs

MVP / VIP
Local time
Today, 02:54
Joined
Jan 14, 2017
Messages
18,216
There are a couple of issues with the set question

Firstly, you need a Boolean field Tour for your checkbox.
The Coupon field in your query should be written as
Coupon: IIf(Tour = True, "Send 10% off next visit", "No Coupon")
Note that using Like isn't really appropriate though it should work if you use Like instead of =
Similarly, using a '?' in the Coupon field is not recommended as its a special character
 

jayrolando

New member
Local time
Yesterday, 21:54
Joined
Mar 25, 2020
Messages
4
There are a couple of issues with the set question

Firstly, you need a Boolean field Tour for your checkbox.
The Coupon field in your query should be written as
Coupon: IIf(Tour = True, "Send 10% off next visit", "No Coupon")
Note that using Like isn't really appropriate though it should work if you use Like instead of =
Similarly, using a '?' in the Coupon field is not recommended as its a special character

Thanks! That worked like a charm. I thought the same thing, in regards to using Like/? but since it asked for it in the instructions, I figured why not do it that way.
 

isladogs

MVP / VIP
Local time
Today, 02:54
Joined
Jan 14, 2017
Messages
18,216
You're welcome. Whoever set the question may not be an Access expert?
 

Users who are viewing this thread

Top Bottom