Refreshing a Subform (1 Viewer)

music_al

Registered User.
Local time
Today, 01:44
Joined
Nov 23, 2007
Messages
200
Hi

I'm adding a record to a table and then I want to be able to see that record in the Datasheet form but its not there. I have to select the datasheet and then click refresh for it to appear. I've tried refresh and requery but nothing seems to work...

Code:
    Forms![frm_Tracker]![multifrm_Master_Staff_List]![dsfrm_Master_Staff_List].Form.SetFocus
    Forms![frm_Tracker]![multifrm_Master_Staff_List]![dsfrm_Master_Staff_List].Form.Refresh
    Forms![frm_Tracker]![multifrm_Master_Staff_List]![dsfrm_Master_Staff_List].Form.Requery

Any help would be appreciated.
 

Ranman256

Well-known member
Local time
Yesterday, 20:44
Joined
Apr 9, 2015
Messages
4,337
did you use the BUILDER to make the path? This doesnt seem correct.
Usu its:
forms!MasterForm!subformName!form!listbox


ALWAYS use the builder to get it correct.
 

music_al

Registered User.
Local time
Today, 01:44
Joined
Nov 23, 2007
Messages
200
I didn't know there was a builder to build VBA code.

I switched round the Requery and Refresh statements and it seems to work.

But, it seems I have to set focus on the form in order to Requery it. Is this correct or is there a way of requerying the form without setting its focus ?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:44
Joined
May 7, 2009
Messages
19,237
check if there is a Link Master/Child Fields on [dsfrm_Master_Staff_List] sub subform.
if it has, try moving [[multifrm_Master_Staff_List] subform to correct related record of sub subform.
 

isladogs

MVP / VIP
Local time
Today, 01:44
Joined
Jan 14, 2017
Messages
18,218
There isn't a VBA builder.
Ranman was suggesting using the builder in the query design window.

The syntax for referring to controls in a subform is
Forms!FormName.SubformContainerName.Form.SubformControlName

However if doing this from the main form, use Me. syntax to simplify that
Me.SubformContainerName.Form.SubformControlName

You do indeed need to set the focus to the subform.
You don't normally need to refresh. Just requery.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 20:44
Joined
Feb 19, 2002
Messages
43,266
For starters, Refresh and Requery are not interchangeable.
1. Requery - does what it says - runs the query from scratch. So new records will be included, deleted records will disappear. Updated records may or may not be included depending on if your query has selection criteria and if the criteria of the updated record matches the criteria.
2. Refresh - updates EXISTING records ONLY. No new records will appear. Records deleted by some other process will be flagged as #deleted# Records that don't match the selection criteria could remain visible.
 

Users who are viewing this thread

Top Bottom