something resetting status of select case or multi-line if statements

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lee weaver
    New Member
    • Aug 2008
    • 23

    something resetting status of select case or multi-line if statements

    I have an odd situtation where a section of code is resetting the status of either multi line If statments which then gives me the error " end if without block if" or something very similure, or select case where it's giving me " Case without Select case"
    here is the offfending code.
    Code:
    Private Sub loginbutton_Click()
    Dim rs As Recordset
    Dim db As Database
    Set db = CurrentDb
    Dim searchstr As String
    'If Not DLookup("Password", "Security", "Employee = " & SelID) = DigestStrToHexStr(Me.pass) Then
        'Exit Sub
    Select Case logasadmin
        Case False
        
            searchstr = "SELECT * FROM Security WHERE Employee = " & Chr(34) & Nz(Me![SelID], 0) & Chr(34)
            Set rs = db.OpenRecordset(searchstr, dbOpenDynaset)
            With rs
            .Fields("Computerlogin") = Environ("username")
            .Update
            .Close
            GBL_login = True
        Case True
        If Nz(DLookup("Password", "Security", "Employee = 666666")) = DigestStrToHexStr(Me.pass) Then
                stDocName = "Adminwarning"
                DoCmd.OpenForm stDocName, , , stLinkCriteria
                GBL_login = True
        End If
    End Select
        searchstr = "SELECT * FROM Security WHERE computerlogin = " & Chr(34) & Nz(Me![userid], 0) & Chr(34)
        If DLookup("password", "Security", "Computerlogin = " & Environ("username")) = DigestStrToHexStr(Me.pass) Then
            GBL_login = True
        End If
    
    
        DoCmd.Close
    End Sub
    it's curently giving the "Case without Select case" on the Case True line.
    Last edited by lee weaver; Jul 22 '10, 02:48 PM. Reason: Misspelling
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    There is no closing End With to match the With rs of line #13.

    Comment

    • lee weaver
      New Member
      • Aug 2008
      • 23

      #3
      Thank you so much!! I have been beating my head on my desk all morning. Microsoft error messages are so helpfull when debugging GRR

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        Pleased to help Lee :)
        Originally posted by lee weaver
        lee weaver: Microsoft error messages are so helpfull when debugging GRR
        Quite true, but you can help yourself there, by using code indenting properly.
        • Properly indented code (whichever system you choose) is invaluable.
        • Non-indented code is hard to read.
        • Badly indented code (where it is indented but not matching any system) is creating a rod for your own back.


        Short version - Indenting properly can help you greatly. Especially with finding bugs.

        Welcome to Bytes!

        Comment

        Working...