ADO Recordset data not showing on form

calendar_today Asked Jul 27, 2016
thumb_up 7 upvotes
history Updated April 14, 2026

Direct Answer

I've had this same issue before and simply adding a blank Form_Load event solved the problem. No code needs to be with the Form_Load it just needs to be present. This is a prose walkthrough, ranked #46th of 95 by community upvote score, from 2016.


The Problem (Q-score 10, ranked #46th of 95 in the VBA Core archive)

The scenario as originally posted in 2016

I’ve got a frustrating issue on MS Access 2010 that I would at this stage qualify as a bug. And after having tried all possible workarounds, I am out of ideas and rely on you.


Context

Huge Ms Access 2010 application with 25k lines of VBA and >50 forms. It has a client server architecture with a frontend compiled and an Access backend on the network. It makes connections to a twentish of different databases (Oracle/SQL Server/Sybase IQ).


The problem

Sometimes when I assign an ADODB recordset to a subform, its data isn’t shown in bound fields. I’ve got #Name? everywhere

The data is there. I can debug.print it, I can see it in the Watches browser, I can read or manipulate it while looping on the recordset object with code. It just not appear in the subform.

It can work flawlessly during months, and suddenly one form will start having this issue without any apparent reason (it might happen even on forms that I have not changed). When it happens, it does for all users, so this is really something wrong in the frontend accdb/accde.

The issue is not related to a specific DBMS/Driver. It can happen with Oracle or Sybase data.

I have created my own class abstracting everything related to ADO connections and queries, and use the same technique everywhere. I’ve got several tenth of forms based on it and most of them works perfectly.

I have this issue in several parts of my application, and especially in a highly complicated form with lots of subforms and code.
On this Main form, a few subforms have the issue, while others don’t. And they have the exact same parameters.


The Code

This is how I populate a form’s recordset :

        Set RST = Nothing
        Set RST = New ADODB.Recordset
        Set RST = Oracle_CON.QueryRS(SQL)

        If Not RST Is Nothing Then
            Set RST.ActiveConnection = Nothing
            Set Form_the_form_name.Recordset = RST
        End If

The code called with Oracle_CON.QueryRS(SQL) is

Public Function QueryRS(ByVal SQL As String, Optional strTitle As String) As ADODB.Recordset

    Dim dbQuery As ADODB.Command
    Dim Output As ADODB.Recordset
    Dim dtTemp As Date
    Dim strErrNumber As Long
    Dim strErrDesc As String
    Dim intSeconds As Long

    Dim Param As Variant

    If DBcon.state <> adStateOpen Then
        Set QueryRS = Nothing
    Else
        DoCmd.Hourglass True

        pLastRows = 0
        pLastSQL = SQL
        pLastError = ""
        pLastSeconds = 0

        Set dbQuery = New ADODB.Command
        dbQuery.ActiveConnection = DBcon
        dbQuery.CommandText = SQL
        dbQuery.CommandTimeout = pTimeOut

        Set Output = New ADODB.Recordset

        LogIt SQL, strTitle

        dtTemp = Now

        On Error GoTo Query_Error

        With Output
            .LockType = adLockPessimistic
            .CursorType = adUseClient
            .CursorLocation = adUseClient
            .Open dbQuery
        End With

        intSeconds = DateDiff("s", dtTemp, Now)

        If Output.EOF Then
            LogIt "-- " & Format(Now, "hh:nn:ss") & " | Executed in " & intSeconds & " second" & IIf(intSeconds = 1, "", "s") & " | Now rows returned."
            Set QueryRS = Nothing
        Else
            Output.MoveLast
            pLastRows = Output.RecordCount
            LogIt "-- " & Format(Now, "hh:nn:ss") & " | Executed in " & intSeconds & " second" & IIf(intSeconds = 1, "", "s") & " | " & Output.RecordCount & " row" & IIf(Output.RecordCount = 1, "", "s") & " returned."
            Output.MoveFirst
            Set QueryRS = Output
        End If

    End If

Exit_Sub:
    pLastSeconds = intSeconds
    Set Output = Nothing
    Set Parameter = Nothing
    Set dbQuery = Nothing

    DoCmd.Hourglass False

    Exit Function

Query_Error:

    intSeconds = DateDiff("s", dtTemp, Now)

    strErrNumber = Err.Number
    strErrDesc = Err.DESCRIPTION
    pLastError = strErrDesc

    MsgBox strErrDesc, vbCritical, "Error " & pDSN

    LogIt strErrDesc, , "ERROR"

    Set QueryRS = Nothing
    Resume Exit_Sub
    Resume
End Function

Things I tried so far

For the recordsets I tried every possible variation of

            .LockType = adLockPessimistic
            .CursorType = adUseClient
            .CursorLocation = adUseClient

The subforms handling the recordsets have all a Snapshot recordsettype, problem remains if I try dynaset.
Dataentry, Addition, deletion, edits are all disabled. It’s pure read-only.

I have a habit of disconnecting the recordsets using RST.ActiveConnection = Nothing so I can manipulate them afterwards, but this doesn’t impact the problem either.

It can happens with very simple queries with only one field in the SELECT clause and only one field bound to it on a subform.

Reimporting all objects in a fresh accdb doesn’t solve the problem either.

The solution proposed by random_answer_guy worked at first glance, which accreditate the bug hypothesis. Unfortunately my problems reappeared after some (totaly unrelated) changes in the main form. I am back with 4 or 5 subforms not showing data and adding/removing a Load event on all or part of them doesn’t make any difference anymore

If you want more information about how weird is this issue, I advise you to read my comment on random_answer_guy‘s answer.


To conclude

What is extremely frustrating is that I can have 2 different forms with exactly the same properties and same fields, same SQL instruction over the same DB, same recordset management code: One is showing the data and the other doesn’t !

When the problem happens, I have no other choice than erasing all objects manipulated and reimporting them from an older version or recreate them from scratch.

If this is not a bug, I am still looking for the proper word to qualify it.

Does anyone ever experienced the issue and has an explanation and/or a workaround to propose ?

Why community consensus is tight on this one

Across 95 VBA Core entries in the archive, the accepted answer here holds niche answer (below median) status — meaning voters are unusually aligned on the right fix.


The Verified Solution — niche answer (below median) (+7)

Verbal answer — walkthrough without a code block

Note: the verified answer is a prose walkthrough. If you need a runnable sample, check VBA Core entries ranked in the top 10 of the same archive.

I’ve had this same issue before and simply adding a blank Form_Load event solved the problem. No code needs to be with the Form_Load it just needs to be present.


When to Use It — classic (2013–2016)

Ranked #46th in its category — specialized fit

This pattern sits in the 94% tail relative to the top answer. Reach for it when your scenario closely matches the question title; otherwise browse the VBA Core archive for a higher-consensus alternative.

What changed between 2016 and 2026

The answer is 10 years old. The VBA Core object model has been stable across Office 2013, 2016, 2019, 2021, 365, and 2024/2026 LTSC, so the pattern still compiles. Changes that might affect you: 64-bit API declarations (use PtrSafe), blocked macros in downloaded files (Mark-of-the-Web), and the shift toward Office Scripts for web-first workflows.

help
Frequently Asked Questions

This is a below-median answer — when does it still fit?
expand_more

Answer score +7 vs the VBA Core archive median ~4; this entry is niche. The score plus 10 supporting upvotes on the question itself (+10) means the asker and 6 subsequent voters all validated the approach.

The answer has no code block — how do I turn it into a snippet?
expand_more

Use the walkthrough above as a checklist, then open a top-10 VBA Core archive entry for a concrete starting template you can adapt.

Published around 2016 — what’s changed since?
expand_more

Published 2016, which is 10 year(s) before today’s Office 2026 build. The VBA Core object model has had no breaking changes in that window. Three things to re-test: (1) blocked macros on downloaded files (Mark-of-the-Web), (2) 64-bit API declarations (PtrSafe, LongPtr), (3) any shift toward Office Scripts for web scenarios.

Which VBA Core pattern ranks just above this one at #45?
expand_more

The pattern one rank above is “MSOFFICE MIME type verification”. If your use case overlaps, compare both before committing.

Data source: Community-verified Q&A snapshot. Q-score 10, Answer-score 7, original post 2016, ranked #46th of 95 in the VBA Core archive. Last regenerated April 14, 2026.

vba