I have a simple form where user selects a "report package" id. when they start the rpt generation process, the first thing I want to do is create an "audit" type record. The rpt gen process will extract data for several groups & plans, and produce output records. I want to create the audit record to track each stage of group processing.
when I run the following code, I get an OBJECT REQUIRED error. What I don't understand is that I copied this code from another app that seems to work just fine. The "source" app is Access 2010, but I am working on a machine where the app must run on the licensed version of Access 2007 installed.
I originally did not have the DAO declaration, but without that, I get a different error, DATA MISMATCH.
any and all help would be greatly appreciated.
when I run the following code, I get an OBJECT REQUIRED error. What I don't understand is that I copied this code from another app that seems to work just fine. The "source" app is Access 2010, but I am working on a machine where the app must run on the licensed version of Access 2007 installed.
I originally did not have the DAO declaration, but without that, I get a different error, DATA MISMATCH.
any and all help would be greatly appreciated.
Code:
Option Compare Database
Const SPACER = " "
Private Sub Create_ReportRun()
On Error GoTo Create_ReportRun_Err
If Me.chkSilent = True Then
DoCmd.SetWarnings False
End If
'START - delete prior process summary data
'Me.txtProcLog = Me.txtProcLog & vbCrLf & vbCrLf & " Deleting Process Summary Detail records ... done."
'DoCmd.OpenQuery ("qDelete_ProcessSummary_Detail")
'Me.txtProcLog = Me.txtProcLog & vbCrLf & " Deleting Process Summary records ... done."
'DoCmd.OpenQuery ("qDelete_ProcessSummary")
'END
Dim myDB As DAO.Database
Dim myRS As DAO.Recordset
Set myDB = CurrentDb
Set myRS = CurrentDb.OpenRecordset("SELECT * FROM ReportRun")
With myRS
.AddNew
![RptPkgID] = Me.cboRptPkgID
![RptRunDate] = CLng(e.txtRunDate)
![RptRunTime] = CLng(Me.txtRunTime)
![ProcStart] = Me.txtStart
.Update
.Close
End With
Set myRS = Nothing
Create_ReportRun_Exit:
DoCmd.SetWarnings True
Exit Sub
Create_ReportRun_Err:
MsgBox Error$ & SPACER & "Create_ReportRun"
Resume Create_ReportRun_Exit
End Sub
Private Sub btnGo_Click()
On Error GoTo btnGo_Click_Err
Dim dtStartDate As Date
If Me.chkSilent = True Then
DoCmd.SetWarnings False
End If
dtStartDate = Now()
Me.txtRunTime = Format(dtStartDate, "hhnn")
Me.txtRunDate = Format(dtStartDate, "yyyymmdd")
Me.txtStart = dtStartDate
Call Create_ReportRun
Me.txtFinish = Now()
btnGo_Click_Exit:
DoCmd.SetWarnings True
Exit Sub
btnGo_Click_Err:
MsgBox Error$ & SPACER & "btnGo_Click"
Resume btnGo_Click_Exit
End Sub
Last edited: