IF Functions

wildexodus

Registered User.
Local time
Today, 09:28
Joined
Feb 6, 2003
Messages
74
I was just wondering if there was an MS Access equivalent to the IF Functions in MS Excel.
 
Look up the IIF() function.
 
Okay, i have some code in the control source of a text box. However i need to add more IIF functions than it will allow. Therefore i tried to get around it by doing this:

=IIF(cboProduct = "Bow" Or "Pillow Sham", ...............

However, this did not work. I know the rest of my code is correct as i tested it. Is there any way to cheat the limit to the number of IIF functions?
 
If you could explain a little bit more on what your trying to do, there may be other options you can look at e.g.

If...Then...Else statements
Select Case

If your using nested IIF functions then it becomes a little cumbersome and confusing to make sure you covered everything. I tend not to use the IIF function where multiple tests have to be made. You might be better off performing you calculations in VBA
 
I would rather do that but i dont really know a lot about access. What kind of code could i use in Visual Basic. I can do the code, but would it need to go in the after update? Also what kind of multiple tests code can you use in VB?
 
nest the iif statements

=IIf( condition, IIf( condition, IIf( condition, if true, if false), if false), if false)
 
what kind of multiple tests code can you use in VB?

The 2 common ones are ones that I mentioned

E.g If...Then...Else

If cboProduct.Value = "Bow" Then
' Code in here to do what you want
If cboProduct.Value = "Pillow Sham" Then
' Do something else
End If
End If

E.g. Select Case

Select Case cboProduct.Value

Case "Bow"
' Code to do what you want here
Case "Pillow Sham"
' Code to do what you want here

End Select

Where you put the code depends on what you are doing. If you are setting the value of a text box based on the selection of a combo box, then you would put it in the AfterUpdate event of the combo box.
 

Users who are viewing this thread

Back
Top Bottom