Run-time error 2448

Gezza

Registered User.
Local time
Tomorrow, 04:03
Joined
Jun 19, 2009
Messages
53
Hi hope someone can help,
The code below gives a Run-time error 2448 on the highlighted line?

Private Sub Form_Open(Cancel As Integer)
Dim LastMonthlyReportDate As Date
Dim NewMonthlyReportDate As Date
Dim LastArchiveDate As Date
Forms![frm_HiddenOpen]![txb_NewMonthlyReportDate] = DateSerial(Year(Date), Month(Date) - 1, 1)

LastMonthlyReportDate = Forms![frm_HiddenOpen]![txb_LastMonthlyReportDate]
NewMonthlyReportDate = Forms![frm_HiddenOpen]![txb_NewMonthlyReportDate]

If NewMonthlyReportDate <> LastMonthlyReportDate Then

Forms![frm_HiddenOpen]![txb_LastMonthlyReportDate] = NewMonthlyReportDate

DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_SiteMqtArchive_TF"
DoCmd.OpenQuery "qry_SiteMqtArchive_del"
DoCmd.SetWarnings True

Forms![frm_HiddenOpen]![txb_LastArchiveDate] = DateSerial(Year(Date), Month(Date) - 11, 1)

End If
End Sub
 
What is in CONTROL SOURCE properties,
in the field "LastManthlyReportDate" ???
 
Here, this code does the same thing as what you posted, but simpler. See if it works.
Code:
Private Sub Form_Open(Cancel As Integer)
   With Forms!frm_HiddenOpen
      .txb_NewMonthlyReportDate = DateSerial(Year(Date), Month(Date) - 1, 1)
      .txb_LastMonthlyReportDate = DateSerial(Year(Date), Month(Date) - 1, 1)
      .txb_LastArchiveDate = DateSerial(Year(Date), Month(Date) - 11, 1)
   End With
   
   With CurrentDb
      .Execute "qry_SiteMqtArchive_TF"
      .Execute "qry_SiteMqtArchive_del"
   End With

End Sub
You don't need all those variables. Just use the form references.
Cheers,
Mark
 

Users who are viewing this thread

Back
Top Bottom