going to last record in a subform

G

Guest

I have set th on current event in a main form to count the records on a
subform , to set the focus to a subform, and then i have attempted to get
the subform to go to the last record. Unfortunately all that occurs is that
the main form goes to the last record.

Is there a prticular way to refer to a subform i.e
docmd.gotorecord acdataform ,"subformname", aclast
 
T

tina

make sure you set the focus to the subform first, and then if necessary to a
specific control in the subform, and then try

DoCmd.RunCommand acCmdRecordsGoToLast

hth
 
G

Guest

Have tried that but same result. Main form still moves to last record
on current code:
 
G

Guest

Thank you,
Have tried that, but main form continues to go to last record.

main form on current:
On Error GoTo err1
If Forms![patnames]![episode].Form.RecordsetClone.RecordCount > 1 Then

Forms![patnames]![episode].Form![servdate].SetFocus
DoCmd.RunCommand acCmdRecordsGoToLast
Else
Forms![patnames].Numbersearch.SetFocus
End If
Exit Sub

err1:
If Err.Number = 2465 Or Err.Number = 2105 Then
Forms![patnames].Numbersearch.SetFocus
Err.Clear
Else: MsgBox Err.Number & " " & Err.Description
End If
 
G

Guest

Have found solution previously posted on accessmonster

-- Allen Browne - 08 Jun 2004 07:36 GMT
This code will move to the last record in the subform. Unfortunately, it
will probably scroll all of the other records out the top of the subform.

Dim rs As DAO.Recordset
With Forms![frmApplicant]![fsubRebate].Form
.Requery
Set rs = .RecordsetClone
If rs.RecordCount > 0 Then
rs.MoveLast
.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End With

Mike


Mike said:
Thank you,
Have tried that, but main form continues to go to last record.

main form on current:
On Error GoTo err1
If Forms![patnames]![episode].Form.RecordsetClone.RecordCount > 1 Then

Forms![patnames]![episode].Form![servdate].SetFocus
DoCmd.RunCommand acCmdRecordsGoToLast
Else
Forms![patnames].Numbersearch.SetFocus
End If
Exit Sub

err1:
If Err.Number = 2465 Or Err.Number = 2105 Then
Forms![patnames].Numbersearch.SetFocus
Err.Clear
Else: MsgBox Err.Number & " " & Err.Description
End If

--
Mike


tina said:
make sure you set the focus to the subform first, and then if necessary to a
specific control in the subform, and then try

DoCmd.RunCommand acCmdRecordsGoToLast

hth
 

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