Connecting Tech Pros Worldwide Forums | Help | Site Map

Help with DAO record schedule EOF File Error

Newbie
 
Join Date: Mar 2008
Posts: 6
#1: Mar 19 '08
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.EOF = True) Then

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

Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM TblOneDayOnly
  3. WHERE (ProgIn =3 OR ProgIn =1) AND (ProgOut =3 OR ProgOut =1);
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdExport_Click()
  2. On Error GoTo Finalstep
  3. Dim querystring As String
  4. Dim dbase As DAO.Database
  5. Dim rsSchedules As DAO.Recordset
  6. Dim tempi As Integer
  7. Dim rptcnt As Integer
  8. rptcnt = 0
  9. If (Me.Optgroup.Value = optScheduleweek.OptionValue Or _
  10. Me.Optgroup.Value = optcharAdhweek.OptionValue) And _
  11. (DateTime.Weekday(txtStartDate.Value, 2) <> 5) Then
  12. MsgBox "The start date is not a Friday, Pls select a friday as start date", vbCritical, "Error"
  13. Exit Sub
  14. End If
  15.  
  16. querystring = GetQueryString
  17. If (Len(Trim(querystring)) > 0) Then
  18. Set dbase = CurrentDb
  19. If (Me.Optgroup.Value = OptMonthly.OptionValue) Then
  20. MsgBox "Exporting monthly report for " & CStr(txtStartDate.Value) & _
  21. " to " & CStr(txtEndDate.Value), vbExclamation, "Export"
  22. tempi = 1
  23. Set rsSchedules = dbase.OpenRecordset(querystring)
  24. If rsSchedules.RecordCount > 0 Then
  25. rsSchedules.MoveLast
  26. rptcnt = rsSchedules.RecordCount
  27.  
  28. End If
  29. If rptcnt = 0 Then GoTo Message
  30. CreateMonthlyReport rsSchedules, GetWeekDay(tempi)
  31.  
  32.  
  33. ElseIf (Me.Optgroup.Value = optScheduleweek.OptionValue) Then
  34.  
  35. MsgBox "Exporting One Day Schedule Flight Activity for " & CStr(txtStartDate.Value) & _
  36. " to " & CStr(txtEndDate.Value), vbExclamation, "Export"
  37. Set rsSchedules = dbase.OpenRecordset(querystring)
  38. If Not (rsSchedules.EOF = True) Then
  39. CreateWeeklyScheduleReport rsSchedules
  40. rptcnt = 1
  41. End If
  42. rsSchedules.Close
  43.  
  44. ElseIf (Me.Optgroup.Value = optcharAdhweek.OptionValue) Then
  45.  
  46. MsgBox "Exporting One Day Charter & Adhoc report for " & CStr(txtStartDate.Value) & _
  47. " to " & CStr(txtEndDate.Value), vbExclamation, "Export"
  48. Set rsSchedules = dbase.OpenRecordset(querystring)
  49. If Not (rsSchedules.EOF = True) Then
  50. CreateWeeklyAdhCharReport rsSchedules
  51. rptcnt = 1
  52. End If
  53. rsSchedules.Close
  54. ElseIf (Me.Optgroup.Value = OptArrivalDate.OptionValue) Then
  55.  
  56. MsgBox "Exporting One Day Daily Flight Activity for " & CStr(txtStartDate.Value)
  57. Set rsSchedules = dbase.OpenRecordset(querystring)
  58. If Not (rsSchedules.EOF = True) Then
  59. CreateDailyReport rsSchedules
  60. rptcnt = 1
  61. End If
  62. rsSchedules.Close
  63.  
  64. End If
  65. Message:
  66. dbase.Close
  67. If Me.Optgroup.Value <> optcharAdhweek.OptionValue Then
  68. If (rptcnt = 0) Then
  69. MsgBox "No Repords Found for Excel Export", vbExclamation, "Export"
  70. Else
  71. MsgBox "Export to excel file(s) completed", vbExclamation, "Export Complete"
  72. End If
  73. End If
  74. Set rsSchedules = Nothing
  75. Set dbase = Nothing
  76. End If
  77.  
  78. Exit Sub
  79. Finalstep:
  80. MsgBox Err.Description, vbCritical, "Error"
  81.  
  82. End Sub

Scott Price's Avatar
Moderator
 
Join Date: Jul 2007
Location: Seattle, WA
Posts: 1,314
#2: Mar 19 '08

re: Help with DAO record schedule EOF File Error


You can change:

Expand|Select|Wrap|Line Numbers
  1. 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
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,219
#3: Mar 20 '08

re: Help with DAO record schedule EOF File Error


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...End If Statements to make any logical sense of it.
Reply