Move to Next record on main form from button of subform

MilaK

Registered User.
Local time
Today, 13:30
Joined
Feb 9, 2015
Messages
285
Hello,

Could someone here suggest a better way of moving to next record on a main from from a button on a subfrom?

The following code works but is there a better way? Thanks

Code:
[Forms]![frm_sample_gene_panel]![frm_Change_Gene_Panel].SetFocus

If [Forms]![frm_sample_gene_panel]![frm_Samples].Form.CurrentRecord < [Forms]![frm_sample_gene_panel]![frm_Samples].Form.RecordsetClone.RecordCount Then

Dim varSub2 As Control
Set varSub2 = [Forms]![frm_sample_gene_panel]![frm_Samples]
varSub2.SetFocus
DoCmd.GoToRecord , , acNext

Else

 MsgBox "You have reached the last sample!"

 
End If
 
The following code works but is there a better way? Thanks
Just curious, but in what way do you think it could be "better".
 
Without setting focus on the main form. Thanks
 
Without setting focus on the main form. Thanks

Seems you have to set focus to a control on the main form at least.?

See post 2 of https://www.pcreview.co.uk/threads/next-record-on-parent-form-after-update-of-child-form.2100943/

Little less code if it works though.

Edit: Revisiting that link appears to show the code does not work?
Found this http://stackoverflow.com/questions/25565123/go-to-new-record-in-parent-form

I'd be interested in knowing what works though.? You never know, I might need to so the same thing some time?:D
 
Last edited:

Users who are viewing this thread

Back
Top Bottom