Page 1 of 3 123 LastLast
Results 1 to 15 of 39
  1. #1
    Join Date
    Jan 2023
    Posts
    15

    Recordset issues, get a good record count but no field data. worked till 365

    Private Sub GENERATE01_Click()
    On Error GoTo Err_GENERATE01_Click
    Stop
    Dim rs As DAO.Recordset


    SQL = "SELECT * FROM query1"
    ' SQL = "SELECT * FROM m1tclcropped"
    Set rs = CurrentDb.OpenRecordset(SQL, dbOpenDynaset)

    Stop
    If rs.RecordCount = 0 Then Exit Sub
    rs.MoveFirst
    For XX = 1 To rs.RecordCount


    txt1 = rs!ImlJobID '<-------no field found






    'GET NEXT UNUSED MASTER
    rs.MoveNext

    Next XX

    Exit_GENERATE01_Click:
    Exit Sub


    Err_GENERATE01_Click:
    MsgBox Err.Description


    Resume Exit_GENERATE01_Click

    End Sub

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    So show the sql for query1?

    Have you tried walking through the code?
    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. #3
    Join Date
    Jan 2023
    Posts
    15
    Yes, every line. rs opens but but has no field data.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    No option explicit I assume?
    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

  5. #5
    Join Date
    Jan 2023
    Posts
    15
    win 10 access 365
    explain "no option explicit"

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    Without option explicit, you can make up any old name variable without it being declared.

    Big mistake.
    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

  7. #7
    Join Date
    Jan 2023
    Posts
    15
    Yes, but my issue is "Why no fields attached to record. It reads 37,818 records , then exits"

  8. #8
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,411
    Yes, but my issue is "Why no fields attached to record. It reads 37,818 records , then exits"

    You're missing the point.

    The 'Field not found' might be txt1. Option Explicit would catch that error at compile time as a syntax error.

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    All you're doing is looping over the records, assigning a rs field value to a textbox, then rinse and repeat. If there is a value in the last record, that's what you'll get in the textbox. In addition, if you're trying to populate a recordset you have to put the rs in edit mode and update the rs in the loop. You're not doing that either.
    Probably best to explain what you want to happen rather than show what's not working. Unless I'm mistaken in my analysis I can't see how it ever did anything before, regardless of which version you used.

    This is your problem because the line raises an error? <-------no field found
    Your thread makes no mention of an error so I don't know what to make of that.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    Join Date
    Jan 2023
    Posts
    15
    error 3265
    I stripped out everything but the read section until the data fields populated.
    Once I can see data elements I will add the output file back in and convert the data to a new file.
    this is just a data conversion program.

  11. #11
    Join Date
    Jan 2023
    Posts
    15
    Error 3265 - Item cannot be found in the collection corresponding to the requested name or ordinal. This error is usually caused by a field missing from the database. This is typically caused by the database upgrade scripts being run out of order or by trying to connect the workstation to the wrong database.May 20, 2016

  12. #12
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    I'd start by ensuring that ImlJobID is actually a field in your recordset. You could copy the sql, open a new query in sql view, paste it in, run it and check the fields. I'd also make sure that the field list in in query design view contains that field name. Sometimes the use of alias field names can throw you off.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    Join Date
    Jan 2023
    Posts
    15
    I have done that. The fields exist. 37,818 records. imljobid is there.


    SELECT m1tclcropped.lmlTimecardID, m1tclcropped.lmlJobID
    FROM m1tclcropped;

  14. #14
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    You are not using that domain though?
    You are using query1??????

    Besides just writing a simple sql statement does not prove field exists???
    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

  15. #15
    Join Date
    Jan 2023
    Posts
    15
    Click image for larger version. 

Name:	query1.PNG 
Views:	21 
Size:	29.2 KB 
ID:	49539
    Actually, it does. Querys won't report what isn't there.
    I've been writing code since 1980 and still can't prove a negative.

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Filter Recordset by record count
    By jcc285 in forum Programming
    Replies: 14
    Last Post: 12-05-2017, 09:40 AM
  2. Replies: 4
    Last Post: 12-20-2015, 12:16 PM
  3. Replies: 12
    Last Post: 08-14-2012, 07:06 AM
  4. Replies: 9
    Last Post: 12-15-2010, 01:44 PM
  5. Replies: 1
    Last Post: 11-13-2009, 03:03 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