Activate event not triggering with sub forms on tab control (1 Viewer)

Tompen

Registered User.
Local time
Today, 13:14
Joined
Jul 2, 2014
Messages
12
Hi,

I have been struggling to get around this long enough and I would really appreciate some real expertise.

I have a main form that holds a tab control with a number of sub forms. One of these subforms has a pop up form for adding new records to it. After closing this pop up form I would like to initate code on the sub form where the new record now will appear. One of the things I like to do is simply to set focus to the record the user just added.

My problem is that I cannot seem to get any event to trigger in this setting (bben trying more or less all). If I understand things right the fact that I am using a pop up form and the fact that I am using a tab control both seem to interfer with the Activate event and making it passive.

Any ideas of how I can trigger code on the sub form (after closing the "Add New" pop up form)?

Many thanks!
 

bob fitz

AWF VIP
Local time
Today, 12:14
Joined
May 23, 2011
Messages
4,719
Any ideas of how I can trigger code on the sub form (after closing the "Add New" pop up form)?
Perhaps you could put the code in the "Add New" forms close event
 

Tompen

Registered User.
Local time
Today, 13:14
Joined
Jul 2, 2014
Messages
12
Thanks! That seems definately like the obvious best alternative. That is also where I currently have the requery of the subform which looks like; Forms!frmBase!frmProjects.Form.Requery (just to show the references). Why I'm trying to find another more direct way to address is simply that I seem to get lost in the referencing when I go into a bit more advanced stuff. Would you also have a good idea of how I would do the referencing in a Setfocus procedure to accomplish what I want to do with setting focust to the record that was just added on the pop up form? (As you see I'm a bit blind on this arena)

Appreciate you guidance!
 

vbaInet

AWF VIP
Local time
Today, 12:14
Joined
Jan 22, 2010
Messages
26,374
After Requerying the subform set focus to it and use the GoToRecord command:
Code:
With Forms!frmBase!frmProjects
    .Form.Requery
    .SetFocus
End With

GoToRecord acActiveDataObject,,acLast
This of course depends on whether record is sorted by the ID. If it isn't then you need to use the Subform's RecordsetClone to find and move to the record.
 

Tompen

Registered User.
Local time
Today, 13:14
Joined
Jul 2, 2014
Messages
12
Great!

This seem to be what I need! Thanks!
 

vbaInet

AWF VIP
Local time
Today, 12:14
Joined
Jan 22, 2010
Messages
26,374
By the way that should have been DoCmd.GoToRecord and not just GoToRecord. Strange I didn't include it.
 

Users who are viewing this thread

Top Bottom