Switchboard command causes run-time error

J

Jedster

I am attempting to build a report function that bases itself on criteria entered onto a dialogue form. This form is initially accessed from a standard switchboard control. However, when this function has run and I later return to the switchboard to select the “Return to main switchboard†option, I receive the following error message

“Run-time error ‘-2147417848 (80010108)’: Method ‘MoveNext’ of object ‘_Recordset’ failedâ€

This seems to refer to the following fragment of code contained within the switchboard

If (rs.EOF) The
Me![OptionLabel1].Caption = "There are no items for this switchboard page
Els
While (Not (rs.EOF)
Me("Option" & rs![ItemNumber]).Visible = Tru
Me("OptionLabel" & rs![ItemNumber]).Visible = Tru
Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText
'(the debug line indicator points to the following line...
rs.MoveNex
Wen
End I

I am unsure as to the cause of this error, however, I’ve noticed that it only occurs when an option is selected from the switchboard that later executes the SendObject command

I will now detail the code that is contained within the dialogue form

1. On the form’s OnLoad event

Public Sub Form_Load(
'Normalise form settings and populate with dates of previous wee
Me.TabCtl7.Visible = Fals
Me.InsideHeight = 240
Me.tglAddCriteria.Caption = "Set additional criteria >>>
Me.StartDate = Dt.FirstOfWeek -
Me.EndDate = Dt.LastOfWeek -
Me.StartDate.Visible = Tru
Me.EndDate.Visible = Tru
ReportName = "rptDiscontinuedCatalogue
StandardCondition = "SC<99 AND St='D'
DateCondition = " AND DiscDate Between #"
& Format$(Me.StartDate, "mm/dd/yyyy") & "# AND #"
& Format$(Me.EndDate, "mm/dd/yyyy") & "#
StandardCaption = "Preparing discontinued report for
AreaCaption = "all areas,
DateCaption = "dates as specified
BodyMessage = "John," & Chr(10) & Chr(10)
& "Please find attached the latest discontinued product update.
End Su

2. On the cmdWeeklyReport button’s OnClick event

Private Sub cmdWeeklyReport_Click(
'Mail discontinued report using weekly criteri
If Val(Me.cbxAllDates) = -1 The
WhereCondition = "Department<>'94'" &
"AND SC<99 AND St='D'
Els
WhereCondition = "Department<>'94'"
& "AND SC<99 AND St='D' AND DiscDate Between #"
& Format$(Me.StartDate, "mm/dd/yyyy") & "# AND #"
& Format$(Me.EndDate, "mm/dd/yyyy") & "#
End I
Me.Caption = "Preparing report (electrical excluded)...
DoCmd.OpenReport
ReportName:=ReportName,
View:=acViewPreview,
WhereCondition:=WhereConditio
Me.Caption = "Discontinued Report

DoCmd.SendObject acSendReport, , acFormatRTF,
"John Phillips", , ,
"Discontinued Product Update", BodyMessage, Tru
End Su

3. And finally on the Close button’s OnClose event

Private Sub Close_Click(
'Return to Switchboar
On Error GoTo Err_Return_Clic

DoCmd.Clos

Exit_Return_Click
Exit Su

Err_Return_Click
MsgBox Err.Descriptio
Resume Exit_Return_Clic

End Su

I can’t see any obvious reason as to why this code should fail and so I’d be interested to hear if anyone has experienced any similar problems and how they may have got around them. Code examples of any solutions that were found would be most welcome!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top