Results 1 to 3 of 3
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Compiler doesn't like "Exit While"

    Click image for larger version. 

Name:	000.jpg 
Views:	13 
Size:	82.9 KB 
ID:	47444

    There's nothing particularly special about a my simple While loop, so it's a mystery as to why the compiler is complaining?

    I changed the code to a "Do While....Exit Do....... Loop", but why doesn't the Exit While not also work?

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Do While works with Exit Do as you discovered.

    Microsoft recommends using Do...Loop instead of While...Wend as "The Do...Loop statement provides a more structured and flexible way to perform looping."

    The documentation for While...Wend does not offer the Exit structure at While...Wend statement (VBA) | Microsoft Docs
    Last edited by davegri; 03-15-2022 at 10:51 PM. Reason: more detail

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Yes, the $MS description doesn't offer an example. I often code loops through recordsets using "While..........Wend", but this is the first time in recent memory that I had an occasion to exit the loop. With this caper, I'll start using "Do While............ Loop" structure so I don't bump my head again. Even old geezers can change their ways
    Thanks,
    Bill

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

Similar Threads

  1. Replies: 1
    Last Post: 11-17-2016, 10:55 AM
  2. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  3. Compiler won't accept "Excel.Application"
    By GeorgeJ in forum Access
    Replies: 2
    Last Post: 12-03-2014, 06:44 PM
  4. Compiler won't accept "Excel.Application"
    By GeorgeJ in forum Programming
    Replies: 3
    Last Post: 12-03-2014, 06:18 PM
  5. Listbox "On Key Down" Property Forces Exit
    By kdbailey in forum Access
    Replies: 21
    Last Post: 01-03-2014, 02:17 PM

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