How do I Move to the last record in a subform?

S

Steven V. Olson

OK! Here's the problem. I have Access Developer 2000. I
have requeried a form to get the most accurate data.
However, I was working on the last record of the subform.
When I requeried using VBA, the subform resets to the
first record in the form. I have tried using
DoCmd.GoToRecord, and DoCmd.GoToControl, however neither
command recognizes that the subform is even open.
DoCmd.GoToControl does not recognize the subform as a
control.

I changed the code to the following:

Private Sub SelectLensOrSegmentStyle_Click()
On Error GoTo Err_SelectLensOrSegmentStyle_Click

Dim stDocName As String
Dim stLinkCriteria As String
'Declarations for an Open Form command below.

Me.Repaint
Me.Requery
'Requeries the main form.

With Me.[RX Input Form].Form.RecordsetClone
'Make sure there is at least one record.
'RX Input Form is the name of the subform under
'the Other tab of the of the Property Sheet of
'the subform when the main form is opened in
'design view.
If Not (.EOF And .BOF) Then
'Moves to last record on the subform.
.MoveLast
Me.[RX Input Form].Form.Bookmark = .Bookmark
End If
End With

DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, ,
acMenuVer70

stDocName = "Clear Lens Or Segment Styles Form"

stLinkCriteria = "[Rx#]=" & Me![Rx#]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Restore

Exit_SelectLensOrSegmentStyle_Click:
Exit Sub

Err_SelectLensOrSegmentStyle_Click:
MsgBox Err.Description
Resume Exit_SelectLensOrSegmentStyle_Click

End Sub


However, when I run the click event I get the following
error:

"Microsoft Access can't find the field 'l' referred to in
your expression."

It is a message box error prompt, however there is not a
debug choice, so I cannot go in and look at the line in
which the error is occuring. Is it possible I need to use
declarations of the recordsetclone that are more specific?

Help,

Steve Olson
 

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