Repair code for acNext if there is no next record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an event procedure that, amoung other things, selects the next record
in the form. The procedure errors out if it just processed the last record
in the form. How can I address this problem?

Here is the line item: DoCmd.GoToRecord acDataForm,
"frmPurchaseOrdersToSend", acNext
 
Signman said:
I have an event procedure that, amoung other things, selects the next record
in the form. The procedure errors out if it just processed the last record
in the form. How can I address this problem?

Here is the line item: DoCmd.GoToRecord acDataForm,
"frmPurchaseOrdersToSend", acNext


If Me.CurrentRecord < Me.Recordset.RecordCount Then
DoCmd.GoToRecord acDataForm, _
"frmPurchaseOrdersToSend", acNext
End If
 
Thanks, Marshall; that's perfect!

Marshall Barton said:
If Me.CurrentRecord < Me.Recordset.RecordCount Then
DoCmd.GoToRecord acDataForm, _
"frmPurchaseOrdersToSend", acNext
End If
 
Marshall,

Do you know how I could make this work for a subform that errors stating
that the object (form) isn't open.

If Me.CurrentRecord < Me.Recordset.RecordCount Then
DoCmd.GoToRecord acDataForm, "frm_Run_Test", acNext
MsgBox "All fields are filled"

End If
 
Subforms aren't considered to be open Forms, so you can't use GoToRecord,
which needs the name of an open form.

From the subform:
Me.Recordset.MoveNext

From the parent form (replacing NameOfSubFormControl with the name of the
Control, not the Form):
Me.NameOfSubformControl.Form.Recordset.MoveNext

HTH,
 
You asked for a substitute for DoCmd.GoToRecord, which can't be used with a
subform. I gave you 2, depending upon where you are calling it from (Parent
or subform). Not sure what print form has to do with it or what a print form
even is.

HTH,

efandango said:
George,

Thanks for replying, though I'm not sure how your solution would fit my
particular problem, as it's not rlated to a prent form. Rather than paste
in
a great deal of code here, can I refer you to this link of my post about
the
problem:

http://www.microsoft.com/office/com...8ada&catlist=&dglist=&ptlist=&exp=&sloc=en-us
 

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

Back
Top