Results 1 to 5 of 5
  1. #1
    cbh35711 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    40

    End While block problem

    Getting the error "Expected: If or Select or Sub or Function or Type or With or enum or end of statement."



    Regardless of how i change the code, i'm unable to get it to compile.

    Code:
    Set rs = CurrentDb.OpenRecordset("Select * From CashFlowSummary")
    
        While rs.EOF = False
            If Acct_Reference_id = Forms![Loan Details].[Acct_Reference_id] Then Analysis_type = "CashFlow"
                Else: Analysis_type = "Collateral"
            End If
            rs.MoveNext
        End While
    Any assistance would be greatly appreciated.

    Chris

    P.S. I was able to get Do Until and Loop to work instead.

  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,641
    Try replacing "End While" with "Loop"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Show all of the code. Where is the OPen recordset?
    Did you try
    If rs!Acct_Reference_id = Forms![Loan Details].[Acct_Reference_id] Then
    Analysis_type = "CashFlow"
    Else
    Analysis_type = "Collateral"
    End If

  4. #4
    cbh35711 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    40
    Thanks pbaldy. Worked like a charm.

    Orange, I updated the original code.

    Chris

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Happy to help, though I'll be a little surprised if it does what you want. Further to Orange's point, I'm not a fan of mixing the one-line and block formats of If/Then/Else.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Block IF End IF Confusion
    By Phred in forum Programming
    Replies: 11
    Last Post: 03-10-2012, 02:18 PM
  2. Replies: 2
    Last Post: 03-02-2012, 09:17 AM
  3. Replies: 7
    Last Post: 08-13-2010, 02:57 PM
  4. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  5. Flag A Data Block
    By JohnBoy in forum Programming
    Replies: 7
    Last Post: 06-29-2010, 01:18 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