Results 1 to 3 of 3
  1. #1
    Persist is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2010
    Location
    Melbourne Australia
    Posts
    32

    Do While Me.Field <> Nul for looping through records in a query

    My code does what I want – but I did see "overflow errors" as I coded.


    Is my use of Do While <> Nul ok. Can it be improved.

    My Table tTask has fields: Task, Priority
    A query sorts my tasks by Priority
    I Open a form based on this query and run this code

    Code:
        DoCmd.GoToRecord , , acFirst
     
        Do While Me.Task <> Nul
           If Me.Task = "xx" Then
               Me.Priority = 999991
           End If
           DoCmd.GoToRecord , , acNext
        Loop

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Are you trying to compare to Null? VBA is seeing Nul as a variable, not as Null. Unless you declared Nul, VBA will default to Variant type and Variant defaults to empty string value.

    However, cannot compare anything to Null anyway. Review http://allenbrowne.com/casu-12.html

    Do While Not IsNull(Me.Task) Then

    Loop
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Persist is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2010
    Location
    Melbourne Australia
    Posts
    32
    Solved - and so fast. Thankyou.

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

Similar Threads

  1. looping to delete records
    By rwahdan@gmail.com in forum Access
    Replies: 3
    Last Post: 02-19-2018, 06:51 AM
  2. Help with Looping Records
    By jtm013 in forum Programming
    Replies: 7
    Last Post: 04-30-2015, 01:39 PM
  3. do Loops - Not looping thru all records
    By kfschaefer1 in forum Programming
    Replies: 1
    Last Post: 03-27-2014, 11:42 PM
  4. Looping through records in a continous form
    By accessnihon in forum Forms
    Replies: 3
    Last Post: 01-04-2012, 01:04 AM
  5. Looping through Records in SQL
    By make me rain in forum Queries
    Replies: 13
    Last Post: 07-17-2011, 08:58 AM

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