Expression help! need to find which one was entered first

sp00k

Registered User.
Local time
Today, 01:09
Joined
Jan 12, 2009
Messages
40
So basically I have a bunch of text boxes, two of the text boxes gathers dates, and the others gather other info and puts it into a smart key containing keys from the date boxes and other boxes.

The problem is I only want the date from the first date that was inputted. If anyone knows how to do a variable(i used controls to hold the numbers) in expression, that would be perfect

="P" & [rcCarrierName] & "-" & [rcLocationCode] & "-" & [rcDivision] & "-" & [rcProjectName] & "-" & [rcProjectYear] & "-" &

IIF(varQR <> 1,Right([rcQuoteSubmitted],2) & IIf(DatePart("m",[rcQuoteSubmitted])<10,0 & DatePart("m",[rcQuoteSubmitted]),DatePart("m",[rcQuoteSubmitted])) & IIf(DatePart("d",[rcQuoteSubmitted])<10,0 & DatePart("d",[rcQuoteSubmitted]),DatePart("d",[rcQuoteSubmitted])),

IIF(varSA <> 1, Right([rcSiteAwarded) & IIf(DatePart("m",[ rcSiteAwarded])<10,0 & DatePart("m",[ rcSiteAwarded]),DatePart("m",[ rcSiteAwarded])) & IIf(DatePart("d",[ rcSiteAwarded])<10,0 & DatePart("d",[rcQuoteSubmitted]),DatePart("d",[ rcSiteAwarded]))))


Its saying I have the wrong amount of arguments, but can't find the mistake.

Thanks!

[FONT=&quot]
[/FONT]
 
Last edited:
So basically I have a bunch of text boxes, two of the text boxes gathers dates, and the others gather other info and puts it into a smart key containing keys from the date boxes and other boxes.

The problem is I only want the date from the first date that was inputted. If anyone knows how to do a variable(i used controls to hold the numbers) in expression, that would be perfect

="P" & [rcCarrierName] & "-" & [rcLocationCode] & "-" & [rcDivision] & "-" & [rcProjectName] & "-" & [rcProjectYear] & "-" &

IIF(varQR <> 1,Right([rcQuoteSubmitted],2) & IIf(DatePart("m",[rcQuoteSubmitted])<10,0 & DatePart("m",[rcQuoteSubmitted]),DatePart("m",[rcQuoteSubmitted])) & IIf(DatePart("d",[rcQuoteSubmitted])<10,0 & DatePart("d",[rcQuoteSubmitted]),DatePart("d",[rcQuoteSubmitted])),

IIF(varSA <> 1, Right([rcSiteAwarded) & IIf(DatePart("m",[ rcSiteAwarded])<10,0 & DatePart("m",[ rcSiteAwarded]),DatePart("m",[ rcSiteAwarded])) & IIf(DatePart("d",[ rcSiteAwarded])<10,0 & DatePart("d",[rcQuoteSubmitted]),DatePart("d",[ rcSiteAwarded]))))


Its saying I have the wrong amount of arguments, but can't find the mistake.

Thanks!

It took me a while to reformat your statement in order to figure out what you were doing here, and I noticed that not all of your IIf() Statements look like they are complete. The standard format of an IIf() statement is as shown below, and I am led to believe that it must be that way. I am not aware of Optional parameters. Brackets asurrounding numbers indicate function parameters ONLY, and are not part of the code.
Code:
[COLOR=black][FONT=Verdana]IIf([/FONT][/COLOR]
[COLOR=black][FONT=Verdana][B][1][/B]    TestCase, [/FONT][/COLOR]
[COLOR=black][FONT=Verdana][B][2][/B]    Result If TestCase=TRUE, [/FONT][/COLOR]
[COLOR=black][FONT=Verdana][B][3][/B]    Result If TestCase=FALSE[/FONT][/COLOR]
[COLOR=black][FONT=Verdana])[/FONT][/COLOR]

Your code as I reformated it, looks like this.
Code:
[COLOR=black][FONT=Verdana][COLOR=black][FONT=Verdana][COLOR=darkorchid][B]IIf([/B][/COLOR][/FONT][/COLOR]
[COLOR=black][FONT=Verdana][B][COLOR=darkorchid][1][/COLOR][/B]    varQR <> 1,[/FONT][/COLOR]
 
[COLOR=black][FONT=Verdana][B][COLOR=darkorchid][2][/COLOR][/B]    Right([rcQuoteSubmitted],2) & [/FONT][/COLOR]
[COLOR=black][FONT=Verdana]IIf([/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=royalblue][B][1][/B][/COLOR]            DatePart("m",[rcQuoteSubmitted])<10,[/FONT][/COLOR]
[COLOR=black][FONT=Verdana][B][COLOR=royalblue][2][/COLOR][/B]            0 & DatePart("m",[rcQuoteSubmitted]),[/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=royalblue][B][3][/B][/COLOR]            DatePart("m",[rcQuoteSubmitted])[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]    ) & [/FONT][/COLOR]
[COLOR=black][FONT=Verdana]IIf([/FONT][/COLOR]
[COLOR=black][FONT=Verdana][B][COLOR=royalblue][1][/COLOR][/B]            DatePart("d",[rcQuoteSubmitted])<10,[/FONT][/COLOR]
[COLOR=black][FONT=Verdana][B][COLOR=royalblue][2][/COLOR][/B]            0 & DatePart("d",[rcQuoteSubmitted]),[/FONT][/COLOR]
[COLOR=black][FONT=Verdana][B][COLOR=royalblue][3][/COLOR][/B]            DatePart("d",[rcQuoteSubmitted])[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]    ), [/FONT][/COLOR]
 
[B][COLOR=black][FONT=Verdana][COLOR=darkorchid][3][/COLOR][/FONT][/COLOR][COLOR=black][FONT=Verdana][COLOR=red]    IIf([/COLOR][/FONT][/COLOR][/B]
[COLOR=black][FONT=Verdana][COLOR=black][B][COLOR=red][1][/COLOR][/B]        varSA <> 1, [/COLOR][/FONT][/COLOR]
 
[COLOR=black][FONT=Verdana][COLOR=black][B][COLOR=red][2][/COLOR][/B]        Right([rcSiteAwarded) & [/COLOR][/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=black]    IIf([/COLOR][/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=black][B][COLOR=royalblue][1][/COLOR][/B]     DatePart("m",[ rcSiteAwarded])<10,[/COLOR][/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=black][COLOR=royalblue][B][2][/B][/COLOR]     0 & DatePart("m",[ rcSiteAwarded]),[/COLOR][/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=black][COLOR=royalblue][B][3][/B][/COLOR]     DatePart("m",[ rcSiteAwarded])[/COLOR][/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=black]    ) & [/COLOR][/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=black]IIf([/COLOR][/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=black][COLOR=royalblue][B][1][/B][/COLOR]     DatePart("d",[ rcSiteAwarded])<10,[/COLOR][/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=black][COLOR=royalblue][B][2][/B][/COLOR]     0 & DatePart("d",[rcQuoteSubmitted]),[/COLOR][/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=black][COLOR=royalblue][B][3][/B][/COLOR]     DatePart("d",[ rcSiteAwarded])[/COLOR][/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=black]    )[/COLOR][/FONT][/COLOR]
 
[COLOR=black][FONT=Verdana][COLOR=red][B]{ Section [3] is Missing here }[/B][/COLOR][/FONT][/COLOR]
[COLOR=black][FONT=Verdana][COLOR=red][B])[/B][/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=purple][B])[/B][/COLOR][/FONT]
[/FONT][/COLOR]

As long as I reformatted it correctly, then the error is in the code that is dieplayed in RED
 
Last edited:
Thank you guys,(i'll try to keep it in proper format for now on) I'm still getting an error, I basically want it so if the two statements aren't true, then four 0's appear

="P" & [rcCarrierName] & "-" & [rcLocationCode] & "-" & [rcDivision] & "-" & [rcProjectName] & "-" & [rcProjectYear] & "-" &
IIf(
varQR <> 1,

Right([rcQuoteSubmitted],2) &
IIf(
DatePart("m",[rcQuoteSubmitted])<10,
0 & DatePart("m",[rcQuoteSubmitted]),
DatePart("m",[rcQuoteSubmitted])
) &
IIf(
DatePart("d",[rcQuoteSubmitted])<10,
0 & DatePart("d",[rcQuoteSubmitted]),
DatePart("d",[rcQuoteSubmitted]), VarSA = 1
),

IIf(
varSA <> 1,

Right([rcSiteAwarded) &
IIf(
DatePart("m",[ rcSiteAwarded])<10,
0 & DatePart("m",[ rcSiteAwarded]),
DatePart("m",[ rcSiteAwarded])
) &
IIf(
DatePart("d",[ rcSiteAwarded])<10,
0 & DatePart("d",[rcQuoteSubmitted]),
DatePart("d",[ rcSiteAwarded]), VarQR = 1
),
"0000"
)
 

Users who are viewing this thread

Back
Top Bottom