Go to last record on Subform

chrisjames25

Registered User.
Local time
Today, 18:14
Joined
Dec 1, 2014
Messages
404
I have a mainform where i add invoice recrods and they are populated on the subform using the following code

Code:
Dim db As Database
Dim rs As Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("Tbl_TempInvoiceDetail")

rs.AddNew
rs.Fields("BatchNo") = Me.Lst_SearchResults.Column(1)
rs.Fields("Invoice_ID") = Me.Txt_Invoice_ID

rs.Update
rs.Close
Set rs = Nothing
db.Close

Me.Frm_ChildInvoiceForm.Requery
'DoCmd.GoToRecord , , acLast

This works great to add the records to the table etc and refresh the subform but the issue is my subform has space for only 10 visible records so when i add the 11th you cant see on the screen it has been added. What i want to do is go to last record at end of code but my current code goes to last record of main form not subform.

Any ideas.

Hopefully explained it ok.
 
If in the subForm,
Me.recordset.movelast

If in main form...

Me.subform.form.recordset.movelast
 
Replace:
Code:
Me.Frm_ChildInvoiceForm.Requery
'DoCmd.GoToRecord , , acLast
With:
Code:
Me.Frm_ChildInvoiceForm.Requery
Me.Frm_ChildInvoiceForm.SetFocus
DoCmd.GoToRecord , , acLast
 
Cheers both for response. Tried both solutions and they both did what i was trying to achieve.

THanks so much.
 

Users who are viewing this thread

Back
Top Bottom