Results 1 to 7 of 7
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IIf Function Behaviour in Subforms (2003)

    If you select August 25, 2005 on the startup form of the attached mdb, you get a message warning that the subform Ore_Marc text box value is zero while it's actually 8. Why is that, considering that the help document for the IIf function states that, "In a Microsoft Access form or report, however, the IIf function evaluates either truepart or falsepart, whichever is appropriate. Therefore, you need not be concerned about the undesirable side effects of evaluating both arguments if you use the IIf function in a calculated control, query expression, or macro."?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IIf Function Behaviour in Subforms (2003)

    The warning is generated by the PotMedia function; this is called in the control source of the PMedia text box on both subforms. In the first subform, ORE_MARC is 8, but in the second subform, ORE_MARC is 0, and this causes PotMedia to be called.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: IIf Function Behaviour in Subforms (2003)

    >>Therefore, you need not be concerned about the undesirable side effects of evaluating both arguments if you use the IIf function in a calculated control, query expression, or macro.<<

    Absolutely untrue. You pass values to functions and subs, not formulas Both arguments are first evaluated, then the results are passed to the function. From these passed values, it determines what to do.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IIf Function Behaviour in Subforms (2003)

    Thank you Hans,
    Is there any way to have the Warning message box specify that the message refers to the subform contained in the "Gruppo 2" page of the tab control? So the message in this case should be, "Zero working hours in Gruppo 2?".

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IIf Function Behaviour in Subforms (2003)

    Thank you Mark.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IIf Function Behaviour in Subforms (2003)

    The subform doesn't really know that it's on a tab page. If you want generic code, use this in PotMedia:

    MsgBox "Zero working hours in " & CodeContextObject.Name & "?", vbOKOnly + vbExclamation, "Warning!"

    It'll display the name of the subform (Mpne2). If you really want the name of the tab page, you might use a case statement, but that makes it less generic:

    Dim strTab As String
    Select Case CodeContextObject.Name
    Case "Mpne1"
    strPage = "Gruppo1"
    Case "Mpne2"
    strPage = "Gruppo2"
    End Select
    MsgBox "Zero working hours in " & strPage & "?", vbOKOnly + vbExclamation, "Warning!"

  7. #7
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IIf Function Behaviour in Subforms (2003)

    Thank you Hans

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •