iif function not working (1 Viewer)

MungoJerry

New member
Local time
Yesterday, 18:52
Joined
May 8, 2019
Messages
5
Hi all,

I am currently in the process of creating a form that will allow the user to log call types.

I have created a combo box to list multiple reasons for potential calls.

I have tried creating an expression for when the option "other" is selected, a list of additional questions will populate in a text box below.

I have tried two variations of an expression but neither seems to work (See below)

IIf([Reason for Call]="Other","Test","")

With the expression above i have added this under conditional formatting on the textbox.

IIf([Reason for Call]="Other",[Details of Call]="Test","")

With the expression above also added this under conditional formatting but on the Reason for call combo box.

Test is where the addition questions will be added.

Apologies i'm new to using access but would greatly appreciate any help on this issue.
 

June7

AWF VIP
Local time
Yesterday, 17:52
Joined
Mar 9, 2014
Messages
5,465
ConditionalFormatting rules just set textbox colors and availability. What exactly are you expecting?

ConditionalFormatting would not use IIf(). What you show looks like VBA or an expression in textbox ControlSource.
 

Minty

AWF VIP
Local time
Today, 02:52
Joined
Jul 26, 2013
Messages
10,366
If you are doing this in the after update event of the combo box i would use an normal if then type construct;

Code:
If Me.[Reason for Call] = "Other" Then 
    Me.[Details of Call] = "Test"
End If

I would also remove all the spaces and any other special characters from your field names, having to enclose everything in [] is a right PITA and will lead to typos and other issues.
 

MungoJerry

New member
Local time
Yesterday, 18:52
Joined
May 8, 2019
Messages
5
Thank you both for your reply. Please see the below link for a screenshot for hopefully some clarity. Again i'm kinda new to this and not 100% sure if i'm adding this code in the write place.

imgur.com/EugOIug
 

mike60smart

Registered User.
Local time
Today, 02:52
Joined
Aug 6, 2017
Messages
1,908
Hi

I believe you are after a different outcome.

As previously stated this statement :- IIf([Reason for Call]="Other",[Details of Call]="Test","")

Will only populate a Control with the string Test.

I believe what you are after is:-

If the "Reason for Call" = "Other" Then
make the Control "Test" Visible in order to enter data.
 

Minty

AWF VIP
Local time
Today, 02:52
Joined
Jul 26, 2013
Messages
10,366
Take a step back and describe in plain English what you are trying to achieve. Try and avoid database terminology as you may be confusing the issue with that.

As stated conditional formatting won't set values on your form, but it could make something enabled or not.

Is this a continuous form? If not then a simple VBA code may be better suited.
 

MungoJerry

New member
Local time
Yesterday, 18:52
Joined
May 8, 2019
Messages
5
I have provided another screenshot that will hopefully make it easier to understand.

imgur.com/pUhJRET

As you can see in the screenshot, The option for "other" will be input into Reason for Call. Once this option is selected i'm looking for a template "Test" to appear in details for call.
 

Minty

AWF VIP
Local time
Today, 02:52
Joined
Jul 26, 2013
Messages
10,366
So "Test" is simply a longish text string?

If so, the the original code I supplied should work in the After Update event of the first combo.
 

MungoJerry

New member
Local time
Yesterday, 18:52
Joined
May 8, 2019
Messages
5
So "Test" is simply a longish text string?

If so, the the original code I supplied should work in the After Update event of the first combo.


That worked perfectly! Thank you very much!
 

MungoJerry

New member
Local time
Yesterday, 18:52
Joined
May 8, 2019
Messages
5
I Just have one last question.

If Me.[Reason for Call] = "Other" Then
Me.[Details of Call] = "Test"
End If

looking at this script, how would i make it so instead of saying "Test" it would instead format like;

"Device:
Error Code:
OS:
Browser:"

so it would list the 4 options above, each one below the previous?
 

June7

AWF VIP
Local time
Yesterday, 17:52
Joined
Mar 9, 2014
Messages
5,465
Me.[Details of Call] = "Device:" & vbCrLf & "Error Code:" & vbCrLf & "OS:" & vbCrLf & "Browser:"
 

Users who are viewing this thread

Top Bottom