Convert large IIF Expression into a Function.
cboboxID has options 1 through 19. There are 25 chkboxes. The text behind the 25 checkboxes would change slightly depending on the cboboxID selected.
The point of the function would be to return text to fill a memo field/textbox in my database by translating the combination of the selections made from the cboboxID, the 25xcheckboxes and 1x freetextfield into text that gets sent to the person fulfilling the request.
This was obviously too large and not the correct, but below is what my newbie brain created so far:
IIF([cboboxID]=1 And [chkbox1]=True,”chkbox1 standard text:”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox1a]=True,”-chckbox1a standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox1b]=True,”-chkbox1b standard text:”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox1c]=True,”-chckbox1c standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2]=True,”chckbox2 standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2a]=True,”-chckbox2a standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2b]=True,”-chckbox2b standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2c]=True,”-chckbox2c standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2d]=True,”-chckbox2d standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2e]=True,”-chckbox2e standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2f]=True,”-chckbox2f standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2g]=True,”-chckbox2g standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox3]=True,”chckbox3 standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox4]=True,”chckbox4 standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox4a]=True,”-chckbox4a standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox4b]=True,”-chckbox4b standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox4c]=True,”-chckbox4c standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox5]=True,”chckbox5 standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox5a]=True,”-chckbox5a standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox5b]=True,”-chckbox5b standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox5c]=True,”-chckbox5c standard text”,Null) & Chr(13) & Chr(10) &
IIF([cboboxID]=1 And [chkbox6]=True,”-chckbox6 standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox6a]=True,”-chckbox6a standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox6b]=True,”-chckbox6b standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox6c]=True,”-chckbox6c standard text”,Null) & Chr(13) & Chr(10) &
IIF([cboboxID]=2 And [chkbox1]=True,”chckbox1 standard text”,Null) & Chr(13) & Chr(10) & [additionalinfof reetext]
And on and on for each of the 19 cboboxID’s and possible outcomes in order to create this text:
_______________ _______________ ___
Customer has chosen the following:
Chkbox1 standard text:
- Chkbox1a standard text.
- Chkbox1b standard text.
Chkbox2 standard text:
- Chkbox2a standard text.
- Chkbox2b standard text.
- On and on based on the selections made.
Additional info:
Additional info free text here.
_______________ _______________ __
Also, what I created using - Chr(13) & Chr(10) - doesn’t remove spaces in the text when the return is Null. How can I include newlines and correct space formatting within a function? I ended up with:
Customer has chosen the following:
Chkbox1 standard text:
-Chkbox1a standard text.
<weird space>
-Chgkbox1c Standard text.
I think the key might be to create a separate function for each cboboxID. So, 19 different functions,
cboboxID has options 1 through 19. There are 25 chkboxes. The text behind the 25 checkboxes would change slightly depending on the cboboxID selected.
The point of the function would be to return text to fill a memo field/textbox in my database by translating the combination of the selections made from the cboboxID, the 25xcheckboxes and 1x freetextfield into text that gets sent to the person fulfilling the request.
This was obviously too large and not the correct, but below is what my newbie brain created so far:
IIF([cboboxID]=1 And [chkbox1]=True,”chkbox1 standard text:”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox1a]=True,”-chckbox1a standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox1b]=True,”-chkbox1b standard text:”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox1c]=True,”-chckbox1c standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2]=True,”chckbox2 standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2a]=True,”-chckbox2a standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2b]=True,”-chckbox2b standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2c]=True,”-chckbox2c standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2d]=True,”-chckbox2d standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2e]=True,”-chckbox2e standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2f]=True,”-chckbox2f standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox2g]=True,”-chckbox2g standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox3]=True,”chckbox3 standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox4]=True,”chckbox4 standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox4a]=True,”-chckbox4a standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox4b]=True,”-chckbox4b standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox4c]=True,”-chckbox4c standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox5]=True,”chckbox5 standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox5a]=True,”-chckbox5a standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox5b]=True,”-chckbox5b standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox5c]=True,”-chckbox5c standard text”,Null) & Chr(13) & Chr(10) &
IIF([cboboxID]=1 And [chkbox6]=True,”-chckbox6 standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox6a]=True,”-chckbox6a standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox6b]=True,”-chckbox6b standard text”,Null) & Chr(13) & Chr(10) & IIF([cboboxID]=1 And [chkbox6c]=True,”-chckbox6c standard text”,Null) & Chr(13) & Chr(10) &
IIF([cboboxID]=2 And [chkbox1]=True,”chckbox1 standard text”,Null) & Chr(13) & Chr(10) & [additionalinfof reetext]
And on and on for each of the 19 cboboxID’s and possible outcomes in order to create this text:
_______________ _______________ ___
Customer has chosen the following:
Chkbox1 standard text:
- Chkbox1a standard text.
- Chkbox1b standard text.
Chkbox2 standard text:
- Chkbox2a standard text.
- Chkbox2b standard text.
- On and on based on the selections made.
Additional info:
Additional info free text here.
_______________ _______________ __
Also, what I created using - Chr(13) & Chr(10) - doesn’t remove spaces in the text when the return is Null. How can I include newlines and correct space formatting within a function? I ended up with:
Customer has chosen the following:
Chkbox1 standard text:
-Chkbox1a standard text.
<weird space>
-Chgkbox1c Standard text.
I think the key might be to create a separate function for each cboboxID. So, 19 different functions,
Comment