Help with DAO record schedule EOF File Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • accessvbanewbie
    New Member
    • Mar 2008
    • 6

    Help with DAO record schedule EOF File Error

    I keep getting an error stating OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET.

    This error just recently began to happen.
    I am exporting some records to excel into a preformatted report.
    The records are exported successfully but this error pops up before the export is completed.
    When I run the debugger this line gives the error message(OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET)

    If Not (rsSchedules.EO F = True) Then

    Below is my code.
    1.
    querystring is referring to the following query

    [code=sql]SELECT *
    FROM TblOneDayOnly
    WHERE (ProgIn =3 OR ProgIn =1) AND (ProgOut =3 OR ProgOut =1);[/code]

    [code=vb]Private Sub cmdExport_Click ()
    On Error GoTo Finalstep
    Dim querystring As String
    Dim dbase As DAO.Database
    Dim rsSchedules As DAO.Recordset
    Dim tempi As Integer
    Dim rptcnt As Integer
    rptcnt = 0
    If (Me.Optgroup.Va lue = optScheduleweek .OptionValue Or _
    Me.Optgroup.Val ue = optcharAdhweek. OptionValue) And _
    (DateTime.Weekd ay(txtStartDate .Value, 2) <> 5) Then
    MsgBox "The start date is not a Friday, Pls select a friday as start date", vbCritical, "Error"
    Exit Sub
    End If

    querystring = GetQueryString
    If (Len(Trim(query string)) > 0) Then
    Set dbase = CurrentDb
    If (Me.Optgroup.Va lue = OptMonthly.Opti onValue) Then
    MsgBox "Exporting monthly report for " & CStr(txtStartDa te.Value) & _
    " to " & CStr(txtEndDate .Value), vbExclamation, "Export"
    tempi = 1
    Set rsSchedules = dbase.OpenRecor dset(querystrin g)
    If rsSchedules.Rec ordCount > 0 Then
    rsSchedules.Mov eLast
    rptcnt = rsSchedules.Rec ordCount

    End If
    If rptcnt = 0 Then GoTo Message
    CreateMonthlyRe port rsSchedules, GetWeekDay(temp i)


    ElseIf (Me.Optgroup.Va lue = optScheduleweek .OptionValue) Then

    MsgBox "Exporting One Day Schedule Flight Activity for " & CStr(txtStartDa te.Value) & _
    " to " & CStr(txtEndDate .Value), vbExclamation, "Export"
    Set rsSchedules = dbase.OpenRecor dset(querystrin g)
    If Not (rsSchedules.EO F = True) Then
    CreateWeeklySch eduleReport rsSchedules
    rptcnt = 1
    End If
    rsSchedules.Clo se

    ElseIf (Me.Optgroup.Va lue = optcharAdhweek. OptionValue) Then

    MsgBox "Exporting One Day Charter & Adhoc report for " & CStr(txtStartDa te.Value) & _
    " to " & CStr(txtEndDate .Value), vbExclamation, "Export"
    Set rsSchedules = dbase.OpenRecor dset(querystrin g)
    If Not (rsSchedules.EO F = True) Then
    CreateWeeklyAdh CharReport rsSchedules
    rptcnt = 1
    End If
    rsSchedules.Clo se
    ElseIf (Me.Optgroup.Va lue = OptArrivalDate. OptionValue) Then

    MsgBox "Exporting One Day Daily Flight Activity for " & CStr(txtStartDa te.Value)
    Set rsSchedules = dbase.OpenRecor dset(querystrin g)
    If Not (rsSchedules.EO F = True) Then
    CreateDailyRepo rt rsSchedules
    rptcnt = 1
    End If
    rsSchedules.Clo se

    End If
    Message:
    dbase.Close
    If Me.Optgroup.Val ue <> optcharAdhweek. OptionValue Then
    If (rptcnt = 0) Then
    MsgBox "No Repords Found for Excel Export", vbExclamation, "Export"
    Else
    MsgBox "Export to excel file(s) completed", vbExclamation, "Export Complete"
    End If
    End If
    Set rsSchedules = Nothing
    Set dbase = Nothing
    End If

    Exit Sub
    Finalstep:
    MsgBox Err.Description , vbCritical, "Error"

    End Sub[/code]
    Last edited by Stewart Ross; Mar 19 '08, 09:39 PM. Reason: added code tags
  • Scott Price
    Recognized Expert Top Contributor
    • Jul 2007
    • 1384

    #2
    You can change:

    Code:
    If Not(rsSchedules.EOF) Then
    There should be absolutely no need to add the = True part.

    However, from the way you framed your question, you imply that this was working before, but now is not?

    If this is true, I would suspect corruption.

    Regards,
    Scott

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      I'm not speaking for the other Moderators/Experts, but I can almost guarantee you that few will look at your code unless it is properly Formatted and Code Tagged. There are far too many If...End If and If..ElseIf...En d If Statements to make any logical sense of it.

      Comment

      Working...