By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,688 Members | 1,738 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,688 IT Pros & Developers. It's quick & easy.

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

P: 23
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.
Expand|Select|Wrap|Line Numbers
  1. Private Sub loginbutton_Click()
  2. Dim rs As Recordset
  3. Dim db As Database
  4. Set db = CurrentDb
  5. Dim searchstr As String
  6. 'If Not DLookup("Password", "Security", "Employee = " & SelID) = DigestStrToHexStr(Me.pass) Then
  7.     'Exit Sub
  8. Select Case logasadmin
  9.     Case False
  10.  
  11.         searchstr = "SELECT * FROM Security WHERE Employee = " & Chr(34) & Nz(Me![SelID], 0) & Chr(34)
  12.         Set rs = db.OpenRecordset(searchstr, dbOpenDynaset)
  13.         With rs
  14.         .Fields("Computerlogin") = Environ("username")
  15.         .Update
  16.         .Close
  17.         GBL_login = True
  18.     Case True
  19.     If Nz(DLookup("Password", "Security", "Employee = 666666")) = DigestStrToHexStr(Me.pass) Then
  20.             stDocName = "Adminwarning"
  21.             DoCmd.OpenForm stDocName, , , stLinkCriteria
  22.             GBL_login = True
  23.     End If
  24. End Select
  25.     searchstr = "SELECT * FROM Security WHERE computerlogin = " & Chr(34) & Nz(Me![userid], 0) & Chr(34)
  26.     If DLookup("password", "Security", "Computerlogin = " & Environ("username")) = DigestStrToHexStr(Me.pass) Then
  27.         GBL_login = True
  28.     End If
  29.  
  30.  
  31.     DoCmd.Close
  32. End Sub
it's curently giving the "Case without Select case" on the Case True line.
Jul 22 '10 #1

✓ answered by NeoPa

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

Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,769
There is no closing End With to match the With rs of line #13.
Jul 22 '10 #2

P: 23
Thank you so much!! I have been beating my head on my desk all morning. Microsoft error messages are so helpfull when debugging GRR
Jul 22 '10 #3

NeoPa
Expert Mod 15k+
P: 31,769
Pleased to help Lee :)
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!
Jul 22 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.