First, my knowledge of VB and Access is close to none.
I want execute an INSERT SQL statement when an Access report is opened.
I have created my Access report. Then I have created a method for the On Open event of the report that looks like this:
Private Sub Report_Open(Cancel As Integer)
CurrentDb.Execute("INSERT INTO dbo_example VALUE('hello')")
However, if I try to open the report I get the Run-time error 3151 saying that ODBC connection failed.
The Report is linked to a Record Source that is a query. The report works fine if I remove this method. The error is really thrown at that line (CurrenDb.Execute)
How can I get an opened database connection from the Report's event?
Thanks in advance.