IIf formula with text field in query not working (1 Viewer)

Chintsapete

Registered User.
Local time
Today, 04:23
Joined
Jun 15, 2012
Messages
137
Can anybody help, I'm stuck with this. I got a table salaries master I want to extract some info out of and calculate some values. The formula below doesn't work, I'm pretty sure it has to do with [pay period] being a text field. Is there no way to make it work?

'Gross monthly Salary: IIf([Salaries Master]![Pay Period] = "weekly";[Salaries Master]![Daily Wage]*5*52/12,IIf([Salaries Master]![Pay Period] = "monthly";[Salaries Master]![Daily Wage]*20))'

:banghead:
 

pr2-eugin

Super Moderator
Local time
Today, 02:23
Joined
Nov 30, 2011
Messages
8,494
How about this?
Code:
Gross monthly Salary: IIf([Salaries Master]![Pay Period] = "weekly"; ([Salaries Master]![Daily Wage]*5*52)/12; [Salaries Master]![Daily Wage]*20)
 

Chintsapete

Registered User.
Local time
Today, 04:23
Joined
Jun 15, 2012
Messages
137
I tried that before as well, but the same error because (at least I think) the [pay period] is a text field and same error.
Thanks
 

pr2-eugin

Super Moderator
Local time
Today, 02:23
Joined
Nov 30, 2011
Messages
8,494
So is Salaries Master a name of the table?
 

Chintsapete

Registered User.
Local time
Today, 04:23
Joined
Jun 15, 2012
Messages
137
Yes, I had at first a second table in the query and than realize didn't need it, that's why the table name with the field name. I removed the second table now and changed the code to:

Code
Gross monthly Salary: IIf([Pay Period]="weekly";[Daily Wage]*5*52/12;[Daily Wage]*20)
End code
But I still have the same problem though
 

pr2-eugin

Super Moderator
Local time
Today, 02:23
Joined
Nov 30, 2011
Messages
8,494
Can you switch to SQL view and give the entire code please?
 

Chintsapete

Registered User.
Local time
Today, 04:23
Joined
Jun 15, 2012
Messages
137
SELECT [Surname] & " " & [First Name] AS Name, [Salaries Master].[Date of Birth], IIf([Surname] Not Like "*Price*" And [Surname] Not Like "*Meier*" And [Surname] Not Like "*Hjul*","black","White") AS Race, IIf([Titel]="Mr","Male","Female") AS Titel1, "n/a" AS [Disability Status], [Salaries Master].[Date of Engagement], IIf([Surname]="Price","Owner",[Department]) AS [Position Lasy Year], IIf([Surname]="Price","Owner",[Department]) AS [Position this Year], [salaries master]![Hours per day]*[days work/week]*52/12 AS [Hours work Per Month], IIf([UIF Contributor]=Yes,"permanent","Non permanent") AS Permanent, "No" AS Experienced, "Yes" AS [Recruited Loacaly]
FROM [Salaries Master]
GROUP BY [Surname] & " " & [First Name], [Salaries Master].[Date of Birth], IIf([Surname] Not Like "*Price*" And [Surname] Not Like "*Meier*" And [Surname] Not Like "*Hjul*","black","White"), IIf([Titel]="Mr","Male","Female"), "n/a", [Salaries Master].[Date of Engagement], IIf([Surname]="Price","Owner",[Department]), IIf([Surname]="Price","Owner",[Department]), [salaries master]![Hours per day]*[days work/week]*52/12, IIf([UIF Contributor]=Yes,"permanent","Non permanent"), "No", "Yes";
 

pr2-eugin

Super Moderator
Local time
Today, 02:23
Joined
Nov 30, 2011
Messages
8,494
Does this really need to be a GROUP BY totals query? I do not find any reason for it to be. Think you are over complicating something simple.
 

Chintsapete

Registered User.
Local time
Today, 04:23
Joined
Jun 15, 2012
Messages
137
I don't quite follow, but essentially I do need each name from the payroll and there relevant data with it, for a report I need to submit yearly. In the "Salaries Master" table I got the daily wage and all the other data, the problem with it is that the weekly wages are calculated [Daily Wage]*5*52)/12 and the monthly [Daily Wage]*20. I'm aware of that this is not the neatest way to do it but for now I'm stuck with it. I'm not sure how else to do it. Any suggestions?
 

Users who are viewing this thread

Top Bottom