Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    322
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Re: 2 IFs for same event (a2002)

    Elisabeth, I think your question isn't very clear... Do you deal with any problems if you put both If-structures (one after the other) in the same event procedure?

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

    Re: 2 IFs for same event (a2002)

    Elizabeth,

    You can do this more or less any way you want:

    Like this:

    Private Sub Form_Current()
    aadHandleButtons Me

    If Me![fsubHours].Form.RecordsetClone.RecordCount > 0 Then
    Me![fsubHours].Form.Visible = True
    Me!Box141.Visible = True
    Me!cmdHours.Visible = False
    Else
    Me![fsubHours].Form.Visible = False
    Me!Box141.Visible = False
    Me!cmdHours.Visible = True
    End If

    If Me![fsubHours].Form.RecordsetClone.RecordCount > 0 Then
    Me![fsubsubInv].Form.Visible = True
    Me!cmdEquip.Visible = False
    Else
    Me![fsubsubInv].Form.Visible = False
    Me!cmdEquip.Visible = True
    End If
    End Sub

    or like this:

    Private Sub Form_Current()
    aadHandleButtons Me

    If Me![fsubHours].Form.RecordsetClone.RecordCount > 0 Then
    Me![fsubHours].Form.Visible = True
    Me!Box141.Visible = True
    Me!cmdHours.Visible = False
    Me![fsubsubInv].Form.Visible = True
    Me!cmdEquip.Visible = False
    Else
    Me![fsubHours].Form.Visible = False
    Me!Box141.Visible = False
    Me!cmdHours.Visible = True
    Me![fsubsubInv].Form.Visible = False
    Me!cmdEquip.Visible = True
    End If
    End Sub

    The second is slightly more efficient in theory (since the If ... Then ... Else ... construction is used only once), but in practice, you won't notice the difference.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    2 IFs for same event (a2002)

    On my form I display hours of operation for a client. I use a command buttons to open a separate form for entering the information with the following code so that either the command button to enter the data or a subform displaying the entered data is visible.:
    Private Sub Form_Current()
    aadHandleButtons Me
    If Me![fsubHours].Form.RecordsetClone.RecordCount > 0 Then
    Me![fsubHours].Form.Visible = True
    Me!Box141.Visible = True
    Me!cmdHours.Visible = False
    Else
    Me![fsubHours].Form.Visible = False
    Me!Box141.Visible = False
    Me!cmdHours.Visible = True
    End If
    End Sub

    I'd like to do the same thing for entering and displaying equipment which will make two IF...THENs on the same event procedure. Is this doable? If so, it would read:

    If Me![fsubHours].Form.RecordsetClone.RecordCount > 0 Then
    Me![fsubsubInv].Form.Visible = True
    Me!cmdEquip.Visible = False
    Else
    Me![fsubsubInv].Form.Visible = False
    Me!cmdEquip.Visible = True
    End If

    Elizabeth

  4. #4
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 2 IFs for same event (a2002)

    You are a wellspring of good info.

    E

Posting Permissions

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