B
BruceS
Hi, again!
I have an A2K form ("ReportsOrder") whose purpose is to change the sequence
in which a group of reports are produced. It's designed similar to the
"References" dialog, showing a list of items and "Up" and "Dn" buttons to
change the order. It contains a continuous subform ("ReportsOrderSubForm")
with record selectors and the report names.
The code to move the report up or down is in the subform:
Private Sub MoveReportDn()
'Can only be called if not last report in list.
Dim myCur As Integer
Dim myNew As Integer
myCur = Me![RptOrder]
DoCmd.GoToRecord , , acNext
myNew = Me![RptOrder]
Me![RptOrder] = myCur
DoCmd.GoToRecord , , acPrevious
Me![RptOrder] = myNew
Me.Requery
Me.RptOrder.SetFocus
DoCmd.FindRecord myNew
Me.CursorPark.SetFocus
End Sub
Private Sub MoveReportUp()
'Can only be called if not first report in list.
Dim myCur As Integer
Dim myNew As Integer
myCur = Me![RptOrder]
DoCmd.GoToRecord , , acPrevious
myNew = Me![RptOrder]
Me![RptOrder] = myCur
DoCmd.GoToRecord , , acNext
Me![RptOrder] = myNew
Me.Requery
Me.RptOrder.SetFocus
DoCmd.FindRecord myNew
Me.CursorPark.SetFocus
End Sub
I call these procedures using the OnClick of two buttons on the parent form:
Private Sub cmdMoveDn_Click()
Me.ParkingSpot.SetFocus
Forms!ReportsOrder![ReportsOrderSubForm].Form.MoveReportDn
End Sub
Private Sub cmdMoveUp_Click()
Me.ParkingSpot.SetFocus
Forms!ReportsOrder![ReportsOrderSubForm].Form.MoveReportUp
End Sub
Problem: When one these button is clicked, I get the following error:
Run-time Error '2465'
Appliation-defined or object-defined error.
Code compiles without an error. What I've tried:
1) Placed debugging stops in the procedures in the subform, but it never
gets that far.
2) Double-checked the syntax for the call in VBA help ("Call Procedures in a
Subform or Subreport").
3) Placed buttons at the bottom of the subform to call MoveReportUp and
MoveReportDn. It works fine that way.
Would really prefer that buttons be to right of subform so "look" is
consistent with other Windows products.
Anyone know what I'm doing wrong?
Thanks,
Bruce
I have an A2K form ("ReportsOrder") whose purpose is to change the sequence
in which a group of reports are produced. It's designed similar to the
"References" dialog, showing a list of items and "Up" and "Dn" buttons to
change the order. It contains a continuous subform ("ReportsOrderSubForm")
with record selectors and the report names.
The code to move the report up or down is in the subform:
Private Sub MoveReportDn()
'Can only be called if not last report in list.
Dim myCur As Integer
Dim myNew As Integer
myCur = Me![RptOrder]
DoCmd.GoToRecord , , acNext
myNew = Me![RptOrder]
Me![RptOrder] = myCur
DoCmd.GoToRecord , , acPrevious
Me![RptOrder] = myNew
Me.Requery
Me.RptOrder.SetFocus
DoCmd.FindRecord myNew
Me.CursorPark.SetFocus
End Sub
Private Sub MoveReportUp()
'Can only be called if not first report in list.
Dim myCur As Integer
Dim myNew As Integer
myCur = Me![RptOrder]
DoCmd.GoToRecord , , acPrevious
myNew = Me![RptOrder]
Me![RptOrder] = myCur
DoCmd.GoToRecord , , acNext
Me![RptOrder] = myNew
Me.Requery
Me.RptOrder.SetFocus
DoCmd.FindRecord myNew
Me.CursorPark.SetFocus
End Sub
I call these procedures using the OnClick of two buttons on the parent form:
Private Sub cmdMoveDn_Click()
Me.ParkingSpot.SetFocus
Forms!ReportsOrder![ReportsOrderSubForm].Form.MoveReportDn
End Sub
Private Sub cmdMoveUp_Click()
Me.ParkingSpot.SetFocus
Forms!ReportsOrder![ReportsOrderSubForm].Form.MoveReportUp
End Sub
Problem: When one these button is clicked, I get the following error:
Run-time Error '2465'
Appliation-defined or object-defined error.
Code compiles without an error. What I've tried:
1) Placed debugging stops in the procedures in the subform, but it never
gets that far.
2) Double-checked the syntax for the call in VBA help ("Call Procedures in a
Subform or Subreport").
3) Placed buttons at the bottom of the subform to call MoveReportUp and
MoveReportDn. It works fine that way.
Would really prefer that buttons be to right of subform so "look" is
consistent with other Windows products.
Anyone know what I'm doing wrong?
Thanks,
Bruce