please i need help on making data report which the database is access 2007 with accdb format. what connection will i use and how and sample codes. thanks a lot in advance.

Dani AI

Generated

Short practical summary and a small runnable pattern that avoids the design-time DataEnvironment: use ADO with the ACE OLEDB provider for .accdb files, open an ADODB.Recordset, then give that Recordset to the DataReport via its DataSource (DataMember should be an empty string when binding a single recordset). (connectionstrings.com)

Add a reference in the VB6 project to a Microsoft ActiveX Data Objects library (for example ADO 2.8 or whatever is present on the target machine) so the ADODB types compile. (excelanytime.com)

Example (replace names/path with the actual ones from the project):

Private Sub ShowMyReport()
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim rpt As MyDataReport   ' the DataReport class created in the project

    Set cn = New ADODB.Connection
    cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Path\MyDB.accdb;Persist Security Info=False;"

    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open "SELECT * FROM MyTable", cn, adOpenStatic, adLockReadOnly

    Set rpt = New MyDataReport
    Set rpt.DataSource = rs
    rpt.DataMember = ""    ' important when binding a standalone Recordset
    rpt.Show vbModal

    rs.Close: cn.Close
    Set rs = Nothing: Set cn = Nothing: Set rpt = Nothing
End Sub

Notes / troubleshooting

  • The common error "Provider not registered" usually indicates the ACE provider is missing or the bitness (32/64) is wrong. VB6 runs as a 32-bit process, so the installed ACE OLEDB provider must match that (install the 32-bit Access Database Engine when targeting VB6 apps). (stackoverflow.com)
  • Ensure DataReport controls (RptTextBox etc.) have their DataField (and DataMember="" for top-level fields) set in the designer or set them in code before Show. When reports appear to show stale data, explicitly clear or reset the DataSource (set DataSource = Nothing) before re-binding. (experts-exchange.com)

Context: already tried a DataEnvironment approach; the pattern above is the runtime/ADO alternative that many VB6 apps use when working with Access .accdb files and DataReport. ’s question about “how far” is addressed by showing the minimal end-to-end flow (open ACE connection → open Recordset → bind to report → Show).

Recommended Answers

All 2 Replies

>>what connection will i use and how and sample codes.
You want to connect with access 2007 or you want to make report of your db?
Anyway how far you doing this?

>>what connection will i use and how and sample codes.
You want to connect with access 2007 or you want to make report of your db?
Anyway how far you doing this?

i used dataenvironment and add sql commands. but before that i downloaded and install the Microsoft Access 12 Datababase Engine. so that's it same codes same as in ado. thanks for your reply.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.