Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2011
    Posts
    10

    Error: Loop without Do

    I am receiving an error stating that there is a Loop without a Do. I am not sure where the fault lies, because there is a Do

    Private Sub Command28_Click()

    On Error GoTo Err_MyProc


    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim UserIDVar As Variant
    Dim Perm As Variant

    UserIDVar = Me.txt_StoreUserID

    Set db = CurrentDb()
    Set rst = db.OpenRecordset("SELECT RoleID FROM x_UserRoleAssign WHERE UserID =" & UserIDVar, dbOpenDynaset)

    Do While Not rst.EOF

    Perm = rst("RoleID")

    If Perm = 1 Then
    Me.cmd_BusUser.Enabled = True
    End If

    If Perm = 2 Then
    Me.cmd_HelpDesk.Enabled = True
    End If

    If Perm = 3 Then
    Me.cmd_TechUser.Enabled = True
    End If

    If Perm = 4 Then
    Me.cmd_ManUser.Enabled = True

    If Perm = 5 Then
    Me.cmd_AdminUser.Enabled = True
    End If



    rst.MoveNext

    Loop

    db.Close
    rst.Close

    Exit_MyProc:
    Set rst = Nothing
    Set db = Nothing
    Exit Sub


    Err_MyProc:
    MsgBox "Error Message to Follow"
    Resume Exit_MyProc


    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    This If doesn't have an End If

    If Perm = 4 Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    Jan 2011
    Posts
    10
    Tnx! ... Stupid me. Its very late in the evening here...

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    as a purely aesthetic comment, may i suggest using the SELECT CASE statement instead of repeated IFs?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Loop Problem
    By JDPrestige in forum Forms
    Replies: 3
    Last Post: 11-14-2010, 06:48 PM
  2. Loop through subform records
    By asmith in forum Forms
    Replies: 6
    Last Post: 10-06-2010, 10:31 AM
  3. Do While loop
    By jgelpi16 in forum Programming
    Replies: 7
    Last Post: 07-23-2010, 08:21 AM
  4. VBA Loop
    By DreamOn in forum Programming
    Replies: 4
    Last Post: 06-25-2010, 03:35 AM
  5. For Each LOOP statement
    By zambam737 in forum Programming
    Replies: 3
    Last Post: 10-26-2009, 09:59 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums