Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IF Then to display label (AccessXP)

    I have the following code in the form's Open event. If the AuthorizedMonthlyUse field is checked I want it to display a label.

    Private Sub Form_Open(Cancel As Integer)
    DoCmd.Maximize
    If Me.AuthorizedMonthlyUse.Value = -1 Then
    Me.lblUnauthorized.Visible = False
    End If
    End Sub

    This works correctly for the first record. But when I change the display record, with either the navigation buttons or a combo box, the code doesn't work correctly. I have tried requery and found that didn't work right because it went to the first record again. I have tried Me.Refresh in several different locations, such as afterupdate on the combo box I used as a locator and the AuthorizedMonthlyUse control.

    What do I have to do to make a label appear or disappear depending on changes in the AuthorizedMonthlyUse control? I want the label displayed right after the
    AuthorizedMonthlyUse control has been changed and the label display or not displayed when the record is changed.

    Thanks for the help.
    Fay

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

    Re: IF Then to display label (AccessXP)

    You need to put this code in the form's Current event!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IF Then to display label (AccessXP)

    Thanks Mark. But that doesn't work. <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    Fay

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

    Re: IF Then to display label (AccessXP)

    Leave the DoCmd.Maximize in the Form_Open event procedure, but move the If ... Then part to two other event procedures:
    - The OnCurrent event of the form.
    - The AfterUpdate event of the AuthorizedMonthlyUse control.
    The first shows/hides the control as the user moves from record to record, the last does so when the user changes the value of the AuthorizedMonthlyUse check box.

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IF Then to display label (AccessXP)

    I got it to work by adding the Else statement.

    Thanks for the help Mark.

    Fay

  6. #6
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IF Then to display label (AccessXP)

    Thanks Hans. Putting the code in the after update event fixed the problem I had just noted.

    Fay

Posting Permissions

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