A family of Microsoft relational database management systems designed for ease of use.
Hi,
"ODBC--call failed" (error 3146) is only a wrapper: the server's real message is hidden behind it. Two things make a query "work" on its own and fail in a report:
- The datasheet only fetches the first rows. When you run the query, Access shows the first screen and loads the rest as you scroll. The report needs every row (plus its grouping, totals and any subreport), so a problem further down (a row the server can't convert, a query that has become too slow) only shows in the report. A monthly report that broke "this month" after years often means the data grew or a new row is unusual.
- Timeout. A query sent through ODBC is stopped after 60 seconds by default. If the report's run now takes longer, you get exactly this.
To see the real error, paste this in a module, put your report's record source name in it, and run it with F5 (results in the Immediate window, Ctrl+G):
Public Sub TestReportSource()
Dim rs As DAO.Recordset, e As DAO.Error
On Error GoTo Failed
Set rs = CurrentDb.OpenRecordset("YourReportQuery", dbOpenSnapshot)
rs.MoveLast ' forces Access to read every row, like the report
Debug.Print rs.RecordCount & " rows read"
Exit Sub
Failed:
For Each e In DBEngine.Errors
Debug.Print e.Number, e.Description
Next e
End Sub
If it fails, the first lines printed are the driver's own message (permission, conversion, timeout...), which tells you what to fix. If it's a timeout, raise it on that query: CurrentDb.QueryDefs("YourReportQuery").ODBCTimeout = 300 (0 means no limit). If this test reads every row without error, the source is fine and Duane's suggestion (a new report with the same source and a few controls, then adding subreports back one by one) will find the part of the report that fails.
I wrote up the causes of 3146 and how to read DBEngine.Errors here: https://auscult.nbit-tech.fr/en/access-error-3146.html?utm_source=msqa&utm_medium=forum (disclosure: I make Auscult, the linked site).