Show Last Record on Subform

Beerbrewer

Registered User.
Local time
Today, 14:24
Joined
Jul 18, 2002
Messages
22
Clients can receive multiple Mailings. Therefor I have a subform Mailings on a mainform Clients. Is it possible to show the last mailing of each client at first when I switch bewteen the clients?
- Docmd.GoToRecord causes some problems, because it interrupts another code.
- Sorting (descending) has the problem when a new Mailingrecord is inserted. It will come right after the first!?

Thank you.
 
What about...

DoCmd.RunCommand acCmdRecordsGoToLast

HTH
 
Thank you for your answer but I get the same error:
Run-time error 2001: You canceled the previous operation.
When clicked on Debug the line
Me.Bookmark = rs.Bookmark
is highlighted. That line is used to find a record, but to show the last record on my subform is activated "On Current". The two codes are shown below:

Private Sub SearchClient_AfterUpdate()
' Find the record that matches the control.

Dim Client
Client = Me!SearchClient
Set rs = Me.Recordset.Clone
rs.FindFirst "[BillToNO] = " & Client

If rs.NoMatch Then
DoCmd.GoToRecord , , acNewRec
Me!SearchClient = Client
Else
Me.Bookmark = rs.Bookmark
End If

End Sub

Private Sub Form_Current()
Forms!FM_Client!FM_Mailing!Pages.SetFocus
DoCmd.GoToRecord , , acLast
Forms!FM_Client!SearchClient.SetFocus

Me![SearchClient] = Me![BillToNO]
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

End Sub

IS THERE A SOLUTION?
Thanks again.
 
Why not combine the codes so that it goes to a new recors after the search update ie.

Private Sub SearchClient_AfterUpdate()
' Find the record that matches the control.

Dim Client
Client = Me!SearchClient
Set rs = Me.Recordset.Clone
rs.FindFirst "[BillToNO] = " & Client

If rs.NoMatch Then
DoCmd.GoToRecord , , acNewRec
Me!SearchClient = Client
Else
Me.Bookmark = rs.Bookmark
End If

Forms!FM_Client!FM_Mailing!Pages.SetFocus
DoCmd.GoToRecord , , acLast
Forms!FM_Client!SearchClient.SetFocus

Me![SearchClient] = Me![BillToNO]
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70 'What is this for as I'm sure there will be a better RunCommand fot this line

end sub

and remove the form_current code
 

Users who are viewing this thread

Back
Top Bottom