locked
First Boolean not working! RRS feed

  • Question

  • When I enter my Code word "sweden" it is not over riding my other codes below when they are false , any help please.....Bob

    Private Sub cmdOwnerStatement_Click()
    'StableSize Security Company Info Code
    Dim bStableSizeCode As Boolean
    Dim bCode1 As Boolean
    Dim bCode2 As Boolean
    Dim bCode3 As Boolean
    Dim bCode4 As Boolean
    Dim bCode5 As Boolean
    Dim bCode6 As Boolean


    '(x)-------------Security Code Test to Over Ride all Codes---------------------

    bStableSizeCode = False
    If (0 < Len([StableSizeCode])) Then
        If ("sweden" = Left$([StableSizeCode], 16)) Then
                bStableSizeCode = True
       DoCmd.Close acForm, "frmBillStatement"
       DoCmd.OpenForm "frmBillStatement", acNormal, , , , acDialog, "OwnerStatement"
       Else
              
     
        End If
    End If

    '(1)---------------Test for 1st letter in the Company Name--------------
    bCode1 = False
    If (0 < Len([tbComCode])) Then
        If (Me.tb1Code.value = Mid$([tbComCode], 2, 1)) Then ' <-2nd letter in Company Name
               bCode1 = True
        End If
    End If
    '(2)---------------Tests for 1st letter in the Email Name--------------------
    bCode2 = False
    If (0 < Len([tbEmailName])) Then
        If (Me.tb2Code.value = Left$([tbEmailName], 1)) Then ' <-1st letter in Email Name
               bCode2 = True
        End If
    End If
    '(2)---------------Tests for 2nd letter in the Email Name--------------------
    bCode3 = False
    If (0 < Len([tbEmailName])) Then
        If (Me.tb3Code.value = Mid$([tbEmailName], 2, 1)) Then ' <- 2nd letter in Email Name
           bCode3 = True
        End If
    End If

    '(4)---------------Tests for 1st letter in the Email Address--------------------
    bCode4 = False
    If (0 < Len([tbCompanyEmail])) Then
        If (Me.tb4Code.value = Left$([tbCompanyEmail], 1)) Then ' <- First letter in Email Address
           bCode4 = True
        End If
    End If

    '(5)---------------Tests for 1st letter in the Bank Name----------
    bCode5 = False
    If (0 < Len([tbDirectBank])) Then
        If (Me.tb5Code.value = Left$([tbDirectBank], 1)) Then '<- First letter in Bank Name
            bCode5 = True
        End If
    End If

    '(6)----------------Tests for 1st letter in the Bank Address---------------------
    bCode6 = False
    If (0 < Len([tbDirectBranch])) Then
        If (Me.tb6Code.value = Left$([tbDirectBranch], 1)) Then '<- First letter in Bank Address
           bCode6 = True
        End If
    End If


    If ((Not bCode1) Or (Not bCode2) Or (Not bCode3) Or (Not bCode4) Or (Not bCode5) Or (Not bCode6)) Then
      MsgBox "Incorrect Entered Code for this Database!", , "StableSize Security"
       DoCmd.Quit
       End If

     DoCmd.Close acForm, "frmBillStatement"
               DoCmd.OpenForm "frmBillStatement", acNormal, , , , acDialog, "OwnerStatement"
           
    Exit Sub
     
     
     
                 
    End Sub

    Thursday, February 10, 2011 12:01 AM

Answers

  • Bob,

    I don't see how why the form wouldn't open. Right at the bottom of your code just before "Exit Sub".

    You close the Form and open the Form in dialog mode with Args. You open the Form without the nested If Else Then.

    If it's not what you wanted, remove the lines just above Exit Sub.

    • Marked as answer by Bruce Song Tuesday, February 15, 2011 10:11 AM
    Thursday, February 10, 2011 1:23 AM
  • bStableSizeCode = False
    If (0 < Len([StableSizeCode])) Then
        If ("sweden" = Left$([StableSizeCode], 16)) Then
                bStableSizeCode = True
       DoCmd.Close acForm, "frmBillStatement"
       DoCmd.OpenForm "frmBillStatement", acNormal, , , , acDialog, "OwnerStatement"
       Else
              

     I am not sure exactly what you are doing but you probably want an Exit Sub before your Else so the rest of the code doesn't run.

    As it is, the form will be closed already so nothing will have any values so I believe  all your Len() test will be False.


    Mark Annett www.ISPManSys.com
    • Marked as answer by Bruce Song Tuesday, February 15, 2011 10:11 AM
    Thursday, February 10, 2011 1:31 AM

All replies

  • try changing 16 to 6
    Thursday, February 10, 2011 12:12 AM
  • Sorry Suzy, my password had 16 letters just changed it for here , was tested at 16 letters and failed, actually opened   DoCmd.Close acForm, "frmBillStatement" but then produced the Msg Box...........Regards Bob
    Thursday, February 10, 2011 1:02 AM
  • Bob,

    I don't see how why the form wouldn't open. Right at the bottom of your code just before "Exit Sub".

    You close the Form and open the Form in dialog mode with Args. You open the Form without the nested If Else Then.

    If it's not what you wanted, remove the lines just above Exit Sub.

    • Marked as answer by Bruce Song Tuesday, February 15, 2011 10:11 AM
    Thursday, February 10, 2011 1:23 AM
  • bStableSizeCode = False
    If (0 < Len([StableSizeCode])) Then
        If ("sweden" = Left$([StableSizeCode], 16)) Then
                bStableSizeCode = True
       DoCmd.Close acForm, "frmBillStatement"
       DoCmd.OpenForm "frmBillStatement", acNormal, , , , acDialog, "OwnerStatement"
       Else
              

     I am not sure exactly what you are doing but you probably want an Exit Sub before your Else so the rest of the code doesn't run.

    As it is, the form will be closed already so nothing will have any values so I believe  all your Len() test will be False.


    Mark Annett www.ISPManSys.com
    • Marked as answer by Bruce Song Tuesday, February 15, 2011 10:11 AM
    Thursday, February 10, 2011 1:31 AM