Results 1 to 5 of 5

Problem with fetching records

  1. #1
    steenesse is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    9

    Problem with fetching records

    Hi

    I want to printer the ordersheets that have not been printer, but my code keeps printing the same ordersheet ove again as if it does not recognise EOF. What am I doing wrong ?

    I have the following code, but replaced the actualt printing with a messagebox, as I have allready printed enough sheets.

    ---------
    CsSQL = "SELECT ORDER_NO,STORE_NO FROM ORDERSBASIC WHERE Printed = False"
    Set printchk = CurrentDb.OpenRecordset(CsSQL)


    If printchk.EOF Then


    Exit Sub




    Else


    Do While Not printchk.EOF


    MsgBox "print" & printchk.ORDER_NO
    strWhere = "[ORDER_NO] = '" & printchk.ORDER_NO & "'"
    CurrentDb.Execute ("UPDATE ORDERSBASIC SET Printed = True WHERE ORDER_NO ='" & printchk.ORDER_NO & "'")


    Loop

    -------

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    6,961
    theres no need for code,
    cant you just set the report to the recordset and hit print ,and all documents print?

  3. #3
    steenesse is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    9
    I have a script that regularly imports XML files from orders in a folder on a timer into the database, which works fine. I just need to print ordersheets of the new orders after import.

    Quote Originally Posted by ranman256 View Post
    theres no need for code,
    cant you just set the report to the recordset and hit print ,and all documents print?

  4. #4
    Minty is online now Hacker
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    938
    You aren't moving through the records anywhere. Add

    Code:
    printchk.Movenext 
    
    
    Before the Loop

    However this would be much more efficient to print all the records in one hit then update all the records in one hit, rather row by row.
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    steenesse is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    9
    Thanks it worked. !!

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

Similar Threads

  1. Fetching data from multiple tables.
    By bupinder in forum Forms
    Replies: 3
    Last Post: 09-07-2017, 12:20 AM
  2. Replies: 2
    Last Post: 07-13-2015, 11:53 AM
  3. Records displaying Problem
    By drunkenneo in forum Forms
    Replies: 1
    Last Post: 06-25-2013, 07:48 AM
  4. Auto-fetching Data From 3rd Party Program, Access 2007
    By D4WNO in forum Import/Export Data
    Replies: 1
    Last Post: 08-21-2012, 02:24 PM
  5. Table fetching remote server
    By Manotosh in forum Access
    Replies: 2
    Last Post: 10-26-2011, 08:38 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
  •  
Tech Forums: Microsoft Office Forums