Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Nested If (Access 2000)

    I have a problem with nested If.In order to get help i will have to explain my code.I have a control on a form called month.On the OnClick event of the form
    i open a report called RMonths. Depending on the month chosen i can open a report named RMonths.
    I have 2 conditions. The first condition is that the Option group Gebinde should be with value 3.It works fine and i have no problems with this condition.
    The second condition is the check box ChkId. What i want is when i click the ChckId, to open another report called USysrptMonthsCustomer.
    If i do not put the second condition, everything is OK.If i put it, i cannot open any report.Obviously i have bungled with the construction of the If clause
    ans somewhere i have it wrong.
    May i have some help ?

    The code under question is the following

    The OnClick event of the control months:

    If Me![Gebinde] = 3 Then
    If [ChkID] = False Then
    FncMonths ("RMonths")
    ElseIf Me![ChkID] = True Then
    FncMonths ("USysrptMonthsCustomer")
    Clear (Me.Name)
    End If
    Else
    MsgBox " Please disregard size ! "
    End If

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

    Re: Nested If (Access 2000)

    Your code can be simplified a bit:
    <UL><LI>When you call a function as a procedure, there is no need to use brackets (unless you want to pass the argument by value instead of by reference - if this means nothing to you, forget about it for the moment).
    <LI>A check box is either On or Off, True or False, so there is no need for an ElseIf.[/list]What is Clear? Is it a function or procedure defined by you? I don't think it is a valid VBA function (it isn't in Access 97). If you want to clear the contents of Me.Name, use Me.Name = Null.

    If you still have problems, you might need to post the code of FncMonths.

    Revised code:

    If Me![Gebinde] = 3 Then
    If [ChkID] = False Then
    FncMonths "RMonths"
    Else
    FncMonths "USysrptMonthsCustomer"
    ' Not sure about this
    Clear Me.Name
    ' Perhaps Me.Name = Null ??
    End If
    Else
    MsgBox " Please disregard size ! "
    End If

Posting Permissions

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