Refresh calling form

  My main form opens a form that makes changes to the data bound to a subform 
in my main form. Trying to keep everything as generic as possible, what I 
want to do is something like this:

if strParentName <> "" Then
  if CurrentProject.AllForms(strParentName).Isloaded Then
    Forms(strParentName).Filter=Forms(strParentName).Filter (forces refresh)
    For each <subform> in <Parent form reference>
      <force a refresh of that subform>
    Next <subform>
  endif
endif

What's the syntax for the "for each..." structure? 

The subform's record source is a query that calculates remaining quantities. 
The Called Form alters those remaining quantities. There's also another 
subform on the Main form with similar issues.
-- 
Jim
0
Utf
1/19/2010 5:22:01 PM
access.formscoding 7494 articles. 0 followers. Follow

7 Replies
527 Views

Similar Articles

[PageSpeed] 29

Dim ctl As Control

  For each ctl in Forms(strParentName).Controls
    If ctl.ControlType = acSubfrom
      Forms(strParentName).Controls(ctl.Name).Form.Refresh
    End If
  Next ctl

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"JimS" <JimS@discussions.microsoft.com> wrote in message 
news:C55A1C77-11B1-44E1-871C-DAE5844DC673@microsoft.com...
>  My main form opens a form that makes changes to the data bound to a 
> subform
> in my main form. Trying to keep everything as generic as possible, what I
> want to do is something like this:
>
> if strParentName <> "" Then
>  if CurrentProject.AllForms(strParentName).Isloaded Then
>    Forms(strParentName).Filter=Forms(strParentName).Filter (forces 
> refresh)
>    For each <subform> in <Parent form reference>
>      <force a refresh of that subform>
>    Next <subform>
>  endif
> endif
>
> What's the syntax for the "for each..." structure?
>
> The subform's record source is a query that calculates remaining 
> quantities.
> The Called Form alters those remaining quantities. There's also another
> subform on the Main form with similar issues.
> -- 
> Jim 


0
Douglas
1/19/2010 5:38:22 PM
Usually what I do here, to avoid looping controls and finding the ones that 
are subforms, and to also avoid unneccesary refreshing of subforms, is 
something along these lines:

Public Function RefreshSubform(strParent As String, strSubControl As String)
  Forms(strParent).Controls(strSubControl).Requery
End Sub

I run this after the popup detail form is closed.

To answer your question though, a for/next loop might look like this:

Dim ctl As Control
For Each ctl In Forms(frmParentName)
  If ctl.ControlType = acSubform (??? not sure if acSubform is correct) 
    ctl.Form.Refresh 'or maybe
    ctl.Form.Requery 'or, you can just requery the control itself
    ctl.Requery
  End If
Next ctl


-- 
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."  
-Thomas Edison (1847-1931) 



"JimS" wrote:

>   My main form opens a form that makes changes to the data bound to a subform 
> in my main form. Trying to keep everything as generic as possible, what I 
> want to do is something like this:
> 
> if strParentName <> "" Then
>   if CurrentProject.AllForms(strParentName).Isloaded Then
>     Forms(strParentName).Filter=Forms(strParentName).Filter (forces refresh)
>     For each <subform> in <Parent form reference>
>       <force a refresh of that subform>
>     Next <subform>
>   endif
> endif
> 
> What's the syntax for the "for each..." structure? 
> 
> The subform's record source is a query that calculates remaining quantities. 
> The Called Form alters those remaining quantities. There's also another 
> subform on the Main form with similar issues.
> -- 
> Jim
0
Utf
1/19/2010 6:09:01 PM
Doug, I copied your code and pasted it. Looks like ControlType is not a 
property of "ctl" as shown???
-- 
Jim


"Douglas J. Steele" wrote:

> Dim ctl As Control
> 
>   For each ctl in Forms(strParentName).Controls
>     If ctl.ControlType = acSubfrom
>       Forms(strParentName).Controls(ctl.Name).Form.Refresh
>     End If
>   Next ctl
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
> 
> "JimS" <JimS@discussions.microsoft.com> wrote in message 
> news:C55A1C77-11B1-44E1-871C-DAE5844DC673@microsoft.com...
> >  My main form opens a form that makes changes to the data bound to a 
> > subform
> > in my main form. Trying to keep everything as generic as possible, what I
> > want to do is something like this:
> >
> > if strParentName <> "" Then
> >  if CurrentProject.AllForms(strParentName).Isloaded Then
> >    Forms(strParentName).Filter=Forms(strParentName).Filter (forces 
> > refresh)
> >    For each <subform> in <Parent form reference>
> >      <force a refresh of that subform>
> >    Next <subform>
> >  endif
> > endif
> >
> > What's the syntax for the "for each..." structure?
> >
> > The subform's record source is a query that calculates remaining 
> > quantities.
> > The Called Form alters those remaining quantities. There's also another
> > subform on the Main form with similar issues.
> > -- 
> > Jim 
> 
> 
> .
> 
0
Utf
1/19/2010 6:36:01 PM
ControlType is correct. However, acSubfrom should be acSubForm

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"JimS" <JimS@discussions.microsoft.com> wrote in message 
news:707FCAB4-730E-4C73-8230-2D702B73A81A@microsoft.com...
> Doug, I copied your code and pasted it. Looks like ControlType is not a
> property of "ctl" as shown???
> -- 
> Jim
>
>
> "Douglas J. Steele" wrote:
>
>> Dim ctl As Control
>>
>>   For each ctl in Forms(strParentName).Controls
>>     If ctl.ControlType = acSubfrom
>>       Forms(strParentName).Controls(ctl.Name).Form.Refresh
>>     End If
>>   Next ctl
>>
>> -- 
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>> "JimS" <JimS@discussions.microsoft.com> wrote in message
>> news:C55A1C77-11B1-44E1-871C-DAE5844DC673@microsoft.com...
>> >  My main form opens a form that makes changes to the data bound to a
>> > subform
>> > in my main form. Trying to keep everything as generic as possible, what 
>> > I
>> > want to do is something like this:
>> >
>> > if strParentName <> "" Then
>> >  if CurrentProject.AllForms(strParentName).Isloaded Then
>> >    Forms(strParentName).Filter=Forms(strParentName).Filter (forces
>> > refresh)
>> >    For each <subform> in <Parent form reference>
>> >      <force a refresh of that subform>
>> >    Next <subform>
>> >  endif
>> > endif
>> >
>> > What's the syntax for the "for each..." structure?
>> >
>> > The subform's record source is a query that calculates remaining
>> > quantities.
>> > The Called Form alters those remaining quantities. There's also another
>> > subform on the Main form with similar issues.
>> > -- 
>> > Jim
>>
>>
>> .
>> 


0
Douglas
1/19/2010 7:18:36 PM
Good catch...also, you forgot the "then", but then I routinely do, too....


Thanks a bunch!
-- 
Jim


"Douglas J. Steele" wrote:

> ControlType is correct. However, acSubfrom should be acSubForm
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
> 
> "JimS" <JimS@discussions.microsoft.com> wrote in message 
> news:707FCAB4-730E-4C73-8230-2D702B73A81A@microsoft.com...
> > Doug, I copied your code and pasted it. Looks like ControlType is not a
> > property of "ctl" as shown???
> > -- 
> > Jim
> >
> >
> > "Douglas J. Steele" wrote:
> >
> >> Dim ctl As Control
> >>
> >>   For each ctl in Forms(strParentName).Controls
> >>     If ctl.ControlType = acSubfrom
> >>       Forms(strParentName).Controls(ctl.Name).Form.Refresh
> >>     End If
> >>   Next ctl
> >>
> >> -- 
> >> Doug Steele, Microsoft Access MVP
> >> http://I.Am/DougSteele
> >> (no e-mails, please!)
> >>
> >> "JimS" <JimS@discussions.microsoft.com> wrote in message
> >> news:C55A1C77-11B1-44E1-871C-DAE5844DC673@microsoft.com...
> >> >  My main form opens a form that makes changes to the data bound to a
> >> > subform
> >> > in my main form. Trying to keep everything as generic as possible, what 
> >> > I
> >> > want to do is something like this:
> >> >
> >> > if strParentName <> "" Then
> >> >  if CurrentProject.AllForms(strParentName).Isloaded Then
> >> >    Forms(strParentName).Filter=Forms(strParentName).Filter (forces
> >> > refresh)
> >> >    For each <subform> in <Parent form reference>
> >> >      <force a refresh of that subform>
> >> >    Next <subform>
> >> >  endif
> >> > endif
> >> >
> >> > What's the syntax for the "for each..." structure?
> >> >
> >> > The subform's record source is a query that calculates remaining
> >> > quantities.
> >> > The Called Form alters those remaining quantities. There's also another
> >> > subform on the Main form with similar issues.
> >> > -- 
> >> > Jim
> >>
> >>
> >> .
> >> 
> 
> 
> .
> 
0
Utf
1/19/2010 8:04:01 PM
> Forms(strParentName).Controls(ctl.Name).Form.Refresh

Doug

Any reason you see for this not to be just ctl.Form.Refresh ?

Not saying there's anything wrong with your code; just curious.


0
Stuart
1/19/2010 10:39:03 PM
"Stuart McCall" <smccall@myunrealbox.com> wrote in message 
news:ujm8MhVmKHA.2160@TK2MSFTNGP02.phx.gbl...
>> Forms(strParentName).Controls(ctl.Name).Form.Refresh
>
> Doug
>
> Any reason you see for this not to be just ctl.Form.Refresh ?
>
> Not saying there's anything wrong with your code; just curious.

No reason at all, other than the fact it didn't occur to me at the time!

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
 


0
Douglas
1/20/2010 11:38:19 AM
Reply:

Similar Artilces:

Problem with forms custimization
I'm trying to add some fields to Accounts form. I added an "HP Customer" attribute using Deployment Manager of a Boolean type. Then I added the field using System Customization to the Details tab of the Accounts form. It all looks and works very nice in the Account Custimization part of the CRM, but when I go to the Sales module and take a look at the existing account, there is no new field on the form. When I create a new account, still no new field on the form. However, the filed is visible as a column on the list of all accounts. How can I make new fields visible on the for...

DDE calls fails for Word 2007. ?
I am using win32APIs for DDE call eg. DdeInitialize , DdeClientTransaction etc.. Now, if the word document is on local machine then my example works fine. But when i try to access the same file from remote locations ( all rights are granted ), DdeInitialize fails with error code : DMLERR_NO_CONV_ESTABLISHED. is it due to the open issue of Word 2007 ?? ( Network based Trust Locations do not work. Macros in templates hosted in such locations will be disabled. : http://officebeta.iponet.net/en-us/products/FX101517941033.aspx#24 ) ...

Sending Information with Outlook 2003 Custom Forms
I have created a custom message form that is used to transfer information between two parties. I have used a combination of controls (text boxes, check boxes, option buttons, combo boxes) for page 2 of the message that will be used to enter all the information to be transfered. Ideally what would happen is that Party A would partially complete the form and send it to Party B. Party B would then complete the necessary information and return the form to Party A. When information is entered, the form is sent, and the receiver opens the message, all of the controls are blank. There is no...

how do i refresh or sync all?
I am trying to force my mail to refresh, or to look for new mail much like Outlook Express does when you click on "Sync All". Maybe I shouldn't be concerned with this. Does Outlook deliver mail as soon as it is processed by the server or is it sent at preset intervals set by the administrator? Les perhaps you mean Send/Receive ? Still learning wrote: > I am trying to force my mail to refresh, or to look for new mail much like > Outlook Express does when you click on "Sync All". Maybe I shouldn't be > concerned with this. Does Outlook de...

Opening the form
Hi Guys, I am created a consult form, is linked to a query, but when the form is open it shows a data already, I would like to have the form empty no data at all and when the use call the record, shows it, another thing is that I want to create a cancel command button and what I want to do is clear all data from the form. I will appreciate any help high quality Soccer jerseys NBA Jersey tracksuit and jackets, GHD hairstraightener supplier from www.willpa.com Are you a Retail businessman who bother by the purchase price? China Cheapest TOP wholesale website can help yo...

Ive added new fields to my transaction form and cant delete them
I've forgotten how I added them, any ideas? In microsoft.public.money, fpdave wrote: >I've forgotten how I added them, any ideas? Delete the Classification. What program are you using? That did it, much apreciated. I did searches for field, column, etc. On Fri, 22 Oct 2004 18:07:19 GMT, via_newsgroup@please.tnx(Cal Learner-- MVP) wrote: >In microsoft.public.money, fpdave wrote: > >>I've forgotten how I added them, any ideas? > >Delete the Classification. What program are you using? ...

World Wide Calling! Unlimited Incoming Calls. #3
New virtual access anywhere technology lets you call anyone, anywhere in the world, from any phone! Access: http://pt.telextreme.com/743499/components/products_services/join.html ...

Refresh some not Refresh All
Hello. I have a workbook with 10 sheets all of which have external data that needs to be refreshed periodically. Most of the time I only need to refresh 8 of the sheets. Is there a way to refresh just those 8 without having to refresh each one separately? Thanks in advance. You can use a macro to do it. It would go something like this... Sub RefreshSome() Dim wks As Worksheet Dim qt As QueryTable For Each wks In Worksheets Select Case wks.Name Case "Sheet1", "sheet2" Case Else For Each qt In wks.Que...

Need to close mulitple forms
Hello, I need help writing code to close two forms at the click of a button. I have the below code but it keeps erroring out. I want to close a form called "frm_AddtlToolsCasesUIBAll" and the current form that I am on/the form that has the button to close both forms. How should I rewrite this? Private Sub Command87_Click() Dim frm_theOtherForm As Form Set frm_theOtherForm = Forms![frm_AddtlToolsCasesUIBAll].Form frm_theOtherForm.Close Set frm_theOtherForm = Nothing DoCmd.Close End Sub Your help is greatly appreciated. Thanks. Iram Setting a refer...

Forms / Threading / Timers
Hi all I have some trouble with Threading in Forms application. - Standard System.Windows.Forms.Form - OnShown I create a new thread - in this new thread I create a new System.Timers.Timer - On Timer.Elapsed I do some SQL database actions There are no form invoke within the thread/timer and also the form does nothing but always when Timer.Elapsed the form is blocked ... How can this be done ?? Do I have to create a AppDomain get real MultiThreading ?? Thanks and best regards Frank Uray Frank Uray wrote: > Hi all > > I have some trouble with Threading in For...

sending an email form.
Hi There I'm not sure if this is possible. When I complete a piece of work I want to send a standard email asking people to mark the work out of a given criteria. I want to make this as easy as possible for people to do. I was wondering how easy it would be to create a form of some kind that would enable the recipient to just fill in a few boxes and hit a button to return it. Any help with this would be greatly appreciated. Thanks in advance Jamie ...

properties error in the field in the form
I just created a form. On the fields there must be an error in the properties. I can't type in the field and I have the #name? error and the #error Error. It looks like I connected the fields to the underlying table correctly so what should I check? =Employees!Emp_ID =Employees!FirstName =[Salary] thanks, If the fields are bound to textboxes on the form, you do not need to use a reference to the underlying table or query. Emp_ID FirstName Salary should be all you need in the controlname property. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access ht...

Call Initiator/Recipient in Activity? Where?
Where on earth are the references for Call Initiator and Call Recipient for an activity object stored? I need to set them when I create an activity, but have no idea what fields to use since it's completely undocumented. Thanks! David phonecallactivity.xsd. DUH YOU IDIOT! Oh, wait I was the original poster :-P Of course MS COULD have stuck with a naming convention like activityphonecall.xsd, but that'd just make too much sense... ....need...vacation... David >-----Original Message----- >Where on earth are the references for Call Initiator and >Call Recipient fo...

Missing destructor calls on exit
Sorry if this is well covered ground, but many of the tactics I tried to employ from other threads didn't pan out (and most importantly allow me to understand _why_ this is happening). I have a doc/view mdi app. My runtime library is multi-threaded debug DLL. On exit of the application (via file..exit or the X button), I get a bunch of memory leaks. Some from a modeless dialog (whose destructor is not called), the CMainFrame itself (all 2K), the CDocManager, CMultiDocTemplate, and a CCmdTarget (these are created by the CWinApp I believe). A breakpoint gets hit in my CMainFrame (which ...

Survey form for Outlook?
I'm part if the IT support for the Hospice I work at. We are thinking of doing a survey on "How are we doing?". I'm thinking it would be neat if we could make it an Outlook (we are running Outlook 202 and Exchange 5.5) form that the user could respond, fill in and send back. Any thoughts on any existing forms/programs that would let us do that? -- Regards, Hank Arnold ...

Refresh 1 subform from another
I am trying to refresh a subform from another subform and I cannot seem to make it work. I have a button on subform 2 that needs to have subform1 refresh. I used Me.subform1.mainform.form.refresh and I get an error that says Method or Data Member not found. Anyone know what I did wrong? I am thinking I should use ! instead of . but I don't know what the difference is between them. Any help? -- Thanks As Always Rip Ripper wrote: >I am trying to refresh a subform from another subform and I cannot seem to >make it work. I have a button on subform 2 that needs to have su...

Display Count of records from subform on Main form
I need to show a count of records for doc on main form. Doc info is on main form and list of pts is on subform. I have entered an unbound text box on the main form and have tried DCount, ABSSum and Count all I get is 0. This is what I have entered: =DCount([ID]) or ABS(Sum([myfrom].[ID]) and =Count([ID]). Thank you in advance for any help you can provide. Thank you. Try it this way: Create a query with the needed table. Add the id-field to the grid. Total it by Count. Save the query and on the form you place an unbound field. In VBA you can do a Dlookup for the one field in the q...

VWD2008 will not refresh HTML file
I am trying to use the showmodaldialog function to display help files for my website. But when I make modifications to the HTML file, a previous version of that file is displayed from within the VWD environment, even if I just want to debug that file. I have restarted VWD, but the old version is still displayed. When I double-click that same file outside the VWD environment, the modified version is displayed, so I know the changes are being saved. I have searched the entire hard drive and there is no other file with the same name. ...

Cells WON'T stop refreshing automatically
I have a workbook with many worksheets and links that I need to publish externally with links locked so that users won't get the "The workbook you opened contains automatic links..." message. I have gone into <Tools> <Options> <Calculation>, unchecked the <Update Remote References> checkbox, and saved the workbook; however, each time I reopen the saved workbook, the <Update Remote References> checkbox has been rechecked by some mischevious gremlin, and I invariably get the "The workbook you opened contains automatic links..." mess...

Refreshing
Hi !! I ve done a OCX to view certain type of images. The OCX has a dialog in it with buttons. This OCX has been loaded into a html page. When multiple OCX are being placed in the html page I find the images that are displayed flickers. I use invalidate to refresh but refreshing is very fast. What should I do now to make smooth refreshing. Thanx Sudharsan Double buffer the image. Create a memory bitmap, copy to it, the BitBlt to your OCX's HDC. This may increase CPU usage a little. "Sudharsan" <Sudharsan@discussions.microsoft.com> wrote in message news:A72BC9BB-...

Floating form/window?
Hello all. Is there a way to have a "floating" form on an Excel spreadsheet? What I mean is to have a form (with controls) that always is available no matter what worksheet the user clicks on. For my particular project, there will be about 50 worksheets in this one project. What I want is to have a form (or window) that is always available so that the user can add a new member whenever they wish. I thought about using a command button, but then I don't know how to make that button appear on each worksheet. The new member would always be added to the active worksheet (or th...

Clipart Woe -- how to refresh location
How can I refresh the path to the clipart gallery for the clipart files? I have moved the clipart from a network location to the local harddrive and rebuild the artgal50.mmc file, but the gallery still looks to the network location?? Help is greatly appreciated, because searching the MS resources is drivining me nuts Nigel Nigel, they are coming to take you away, take you away. If you hear a knock on the front door, do not open it as it may be the fine gentlemen with a while jacket with straps on. Nigel, you are driving us nuts not telling us what version of Windows and Publisher you...

Popup form does not appear for some users
Access 2003: I have a popup form (Popup=Yes, Modal=No) that appears when I open it on my PC, but does not appear when another user opens it on her PC. I have connected remotely to her PC, can open the form in Design mode, but when I switch to Form View, I can no longer see it. I have checked IE popup blocker, but ironically my popup blocker is on, and her popup blocker is off. Any thoughts? ...

User form
Is there any way to modify the User Form? I want to add a field to the form that is already in the schema...thx The System User form is not editable. There is a way to make it customizable, that is to change the customizable column in the entity table of the _metabase database. This will allow you to publish customizations for this entity. But I would strongly advise not to use this, since it can break your entire CRM system. Also you will loose support from Microsoft. Rob Bakkers, Avanade Netherlands "mark@markhembree.com" wrote: > Is there any way to modify the User F...

forms...when i click "Edit read page"
i'm trying to work on some forms in outlook 2003 and it seems to hang up a lot. specially when i click on edit read page it hangs up and i have to close out outlook and reopen it. i have Sp1 installed....can anyone help please...Thanx ...