Compile Error when form opens

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Elphaba31
    New Member
    • Apr 2010
    • 2

    #1

    Compile Error when form opens

    Hello Gurus,

    I have been tasked with correcting issues with our upgrade(Access9 7/2000 to Access2007) and essentially know very little about Access (any version) or Visual Basic. Here is my current issue: when we open one of our .accdb it throws this error:

    "Compile error: Method or data not found"

    CODE:

    Private Sub Form_Load()
    '20010105 JBT

    Dim RS As Recordset
    Dim SQL As String

    DoCmd.Maximize

    ' *** AUTO STATUS REPORT GENERATOR
    Set RS = CurrentDb.OpenR ecordset("tblMo nthlyTrackings" , dbOpenSnapshot)
    RS.FindFirst "(([Printed] = 0) AND (Month([CallDt]) = Month(Date())-1))"
    If Not RS.NoMatch Then
    If MsgBox("You have Monthly Status records for last month. Do you wish a report printed?", vbYesNo, "UNPRINTED RECORDS FOUND") = vbYes Then
    RS.Close
    DoCmd.OpenRepor t "rptMonthlyStat usReport", acViewPreview

    SQL = "UPDATE tblMonthlyTrack ings SET tblMonthlyTrack ings.Printed = -1 " & _
    "WHERE (((tblMonthlyTr ackings.Printed )=0));"
    CurrentDb.Execu te SQL
    End If
    End If
    CurrentDb.Close
    ' *** end AUTO STATUS REPORT GENERATOR

    End Sub

    (see attached jpeg)

    Can anyone pass on some pointers of how to fix this? A good tutorial would be nice, I'm learning Access 2007 & VB by troubleshooting these errors, so it's peice by peice.

    THANK YOU in advance for your assistance!!
    Attached Files
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Try running the following code making sure to set a Reference to the Microsoft DAO X.X Object Library:
    Code:
    'Make sure that a Reference is set to the Microsoft DAO X.X Object Library
    Dim RS As DAO.Recordset
    Dim SQL As String
    
    DoCmd.Maximize
    
    ' *** AUTO STATUS REPORT GENERATOR
    Set RS = CurrentDb.OpenRecordset("tblMonthlyTrackings", dbOpenSnapshot)
    
    RS.FindFirst "([Printed] = 0) AND (Month([CallDt]) = Month(Date())-1)"
    
    If Not RS.NoMatch Then
      If MsgBox("You have Monthly Status records for last month. Do you wish a report printed?", _
                 vbYesNo, "UNPRINTED RECORDS FOUND") = vbYes Then
        RS.Close
        Set RS = Nothing
    
        DoCmd.OpenReport "rptMonthlyStatusReport", acViewPreview
    
        SQL = "UPDATE tblMonthlyTrackings SET tblMonthlyTrackings.Printed = -1 " & _
              "WHERE (((tblMonthlyTrackings.Printed)=0));"
    
        CurrentDb.Execute SQL
      End If
    End If

    Comment

    • Elphaba31
      New Member
      • Apr 2010
      • 2

      #3
      Wow, Thank you ADezii for your quick response. As soon I get to make the correction I will let you know what happens.

      Again Thank you and I appriciate you time and assistance!

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Hope it all works out for you.

        Comment

        Working...