OBJECT REQUIRED error on simple VB code

sonntagc

New member
Local time
Today, 03:49
Joined
Aug 6, 2013
Messages
3
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.

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:
Hello sonntagc, Welcome to AWF.. :)

Which line are you getting this error?

Could you make sure the CODE tag is closed with Forward Slash? It makes it easier to read with proper indenting..
 
This will likely cause a problem. ;)

![RptRunDate] = CLng(e.txtRunDate)
 
omg!! i was staring at that code for an hour, so i moved on to something else waiting for a reply. totally missed the typo. THANKS Paul you're a life saver.
 

Users who are viewing this thread

Back
Top Bottom