Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    It's so much more obvious what's happening



    Code:
     
        While Not rs.EOF
                
            Select Case rs.Fields("Status")
                
                Case "Delivery"
                    dtDelDate = DLookup("DeliveryDate", "tblAssign", "[Status] = '" & strStatus & "'")
                    strDriver = DLookup("Driver", "tblAssign", "[Status] = '" & strStatus & "'")
                    strVehicle = DLookup("Vehicle", "tblAssign", "[Status] = '" & strStatus & "'")
                    strBody = strBody & rs.Fields("DelTo") & " - " & rs.Fields("Town") & " - " & rs.Fields("PostCode") & " - " & rs.Fields("LiftType") & " - " & _
                        rs.Fields("SONumber") & " - " & rs.Fields("LiftNo") & " - " & rs.Fields("Status") & "Delivered: " & Format(dtDelDate, "ddd-dd-mmm-yyyy") & " Driver: " & strDriver & " Vehicle: " & strVehicle & "|"
                            
                Case "Collection"
                    dtDelDate = DLookup("CollectedDate", "tblCollections", "[Status] = '" & strStatus & "'")
                    srtBody = strBody & rs.Fields("DelTo") & " - " & rs.Fields("Town") & " - " & rs.Fields("PostCode") & " - " & rs.Fields("LiftType") & " - " & _
                        rs.Fields("SONumber") & " - " & rs.Fields("LiftNo") & " - " & rs.Fields("Status") & "Collected: " & Format(dtDelDate, "ddd-dd-mmm-yyyy") & "|"
                 
                Case Else
                    srtBody = srtBody & rs.Fields("DelTo") & " - " & rs.Fields("Town") & " - " & rs.Fields("PostCode") & " - " & rs.Fields("LiftType") & " - " & _
                        rs.Fields("SONumber") & " - " & rs.Fields("LiftNo") & " - " & rs.Fields("Status") & "|"
                
            End Select
            rs.MoveNext
        Wend
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  2. #17
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    Of course even then, you are still overwriting strbody with each record's values.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #18
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    You do have Google, or Bing or something, no? (hint, hint).
    Just my opinion, but you'll likely learn more if you do your own research for such things as it often leads to other things as well. Not only that, whatever we'd put would just be repeating what has already been said elsewhere, with the risk that something erroneous is posted. Here's just one Google result.

    https://stackoverflow.com/questions/...ile-wend-loops
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #19
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,939
    Is this the same or is Wend more reliable than Loop
    much the same, but can depend on what you are doing. 'Do until' can have different requirements to 'while'

  5. #20
    DMT Dave is online now VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,371
    Thanks guy's all appreciated, will read through your suggestions carefully in a short while

    again thank you for your help

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Loop issue
    By onlylonely in forum Programming
    Replies: 35
    Last Post: 07-18-2017, 07:48 PM
  2. Replies: 13
    Last Post: 06-06-2017, 01:43 PM
  3. Replies: 9
    Last Post: 03-07-2017, 02:49 PM
  4. Loop issue
    By dragon_sun252 in forum Programming
    Replies: 25
    Last Post: 04-29-2012, 12:27 AM
  5. Issue with while loop and Access 2007 datasheet
    By jermaine123 in forum Programming
    Replies: 2
    Last Post: 01-17-2010, 10:09 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