IIF statement code problems

trainman

New Member
Joined
Jul 28, 2010
Messages
37
Hi to all the code monkeys out there.
Looking for some guidance.
Could someone please tell me why Access query has no problem reading and running.
Code:
[FONT=Calibri][COLOR=#000000]IIf([POCODE]='B06' And
[R_SDATE]>Now() And ([R_SDATE]<[DUEDATE]) And [DUEQTY]>0 And
([RAISER]="DADAMS2" Or [RAISER]="BCOCHRAN " Or
[RAISER]="BRICH " Or [RAISER]=" JGLANVIL"),1,0) [/COLOR][/FONT]

But spits back

Code:
[FONT=Calibri][COLOR=#000000] IIf([POCODE]='B10' And
[R_SDATE]>Now() And ([R_SDATE]<[DUEDATE]) And [DUEQTY]>0 And
([RAISER]="DGONDA" Or [RAISER]="JGILLAN" Or [RAISER]="
PHICKEY" Or [RAISER]="RBARTLEY" Or [RAISER]=”DBURNS”),1,0)[/COLOR][/FONT]

when I run the query a parameter window comes up asking me to enter a value for DBURNS each time it comes across it in the query..(which is approximatley 16 times)..i just click OK through them and the query runs, it just doesnt seem to take the DBURNS into account ( therefore is inaccurate in it's results).
Another point of interest is when i go back and look at the code..it has changed all instances of "DBURNS" to [DBURNS] ( which explains the asking for a value as it thinks it is a field.)
ANY advice you can provide would be great..I have spent quite a bit of time scratching my head over this one..
thanks in advance
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
The quotes around DBURNS don't look quite right.

I've changed them here and introduced an IN clause.
Code:
 IIf([POCODE]='B10' And
[R_SDATE]>Now() And ([R_SDATE]<[DUEDATE]) And [DUEQTY]>0 And
[RAISER]  In ("DGONDA", "JGILLAN", 
"PHICKEY" ,"RBARTLEY","DBURNS"),1,0)
 
Upvote 0
Thanks Norie,
I noticed the quote marks myself and thought they didnt look quite right..as a matter of fact ..that was the ONLY thing i could find that looked off prior to posting.
I will give your solution a try.
thanks again
 
Upvote 0
Update:
I pasted the SQL code into Notepad and redid the quote marks.
All worked just fine.
Originally made modifications to the code via a cut and paste into Microsoft WORD.
something to be mindful of on future projects.
 
Upvote 0

Forum statistics

Threads
1,223,625
Messages
6,173,395
Members
452,514
Latest member
cjkelly15

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top