Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Using yes/no to determine if form should load (2002)

    Hi,

    I have a form that is used as a password form. It is bound to tblPasswords and contains a yes/no check box [required]. In instances where the office does not require a password for the form, it does not need to load but instead a different form opens. If [required] = false then frmGeneralLedger should open, if [required]=true then frmGLPassword should open. I've tried using both of the following pieces of code on the load event of frmGLPassord. The problem is that frmGLPassword opens no matter what the value of [required] is. What am I missing?

    'Looks to see if password is required or not. If not required, bypasses password form
    __________________________________________________ __________________________
    If IsNull(Me.Required) Then
    DoCmd.OpenForm "frmGeneralLedger", acNormal
    Exit Sub


    Else:

    'Loads password text box as null

    Me.txtPassword = Null
    __________________________________________________ _____________________

    'Looks to see if password is required or not. If not required, bypasses password form

    If Me.Required.Value = "false" Then
    DoCmd.OpenForm "frmGeneralLedger", acNormal
    Exit Sub

    Else:

    'Loads password text box as null

    Me.txtPassword = Null
    End If

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using yes/no to determine if form should load (2002)

    Assuming your checkbox is named Required, try this:

    <code>If Me.Required = False Then
    DoCmd.OpenForm "frmGeneralLedger", acNormal
    Exit Sub

    Else:

    'Loads password text box as null

    Me.txtPassword = Null
    End If</code>

    What you were missing is the fact that True and False are VBA constants, not strings. A checkbox value cannot be equal to a string.
    Charlotte

  3. #3
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using yes/no to determine if form should load (2002)

    God, if you only knew how long I played with that one. I swear to god I'll never get strings vs constants etc. Just when I think I'm getting it, I'm not. About the only thing I do get is that with Access its one step building on the next etc. It's so frustrating!

    Thanks Charlotte, I appreciate the help and the the info on why my code wasn't working.

    Leesha

Posting Permissions

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