473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Refresh another Form

Hi All,

I am trying to refresh a textbox in form A while in Form B from an OnClick (both forms are open at the same time) - I want to write the below function but do not seem to be able to get this right. I have tried Requery but it does work ?

need something like

Expand|Select|Wrap|Line Numbers
  1. [Forms]![tbl_Ronnie_Master]![Textbox].Refresh
  2.  
any help/advise will be appreciated
Thanks
Nov 5 '09 #1
9 17151
ajalwaysus
266 Expert 100+
Is one of these a subform in the other, or are they 2 independent forms?

-AJ
Nov 5 '09 #2
Hi AJ,

No they are two independant forms, the only reason I did not do a subform is becuase I need to see both as continuous. one form changes a calculation after filters are applied, i would like another text box in a another form to pick this up everytime a filter is changed (general idea) - if you have a better way of doing it then please advise
Nov 5 '09 #3
ajalwaysus
266 Expert 100+
Well one thing I would recommend first is to ask if it is possible to make both these forms subforms in a main form, that way, first off you can pull up both forms at the same time and position by calling the main form. Then if you did that, you could refresh Form B from Form A with this code:

Expand|Select|Wrap|Line Numbers
  1. Me.Parent.FormB.Requery
Or else, I am not sure if you can call a requery on an independent form from another. I could very well be wrong and hope someone corrects me if I am.

-AJ
Nov 5 '09 #4
This is how I have two forms communicate. I set a form variable to the instance of the open form. I 'use the form's class name instead of form.
This way VBA returns all controls, public subs and functions
when typing the dot after the form variable.

Expand|Select|Wrap|Line Numbers
  1. Private frmDrawing As Form_Drawings  
  2.  
  3. Private Sub Form_Open(Cancel As Integer)
  4.     GetLoadedForm "Drawings", frmDrawing
  5.     Me.DJob.DefaultValue = "'" & frmDrawing.DJob & "'"
  6.     Me.DJob.Requery
  7. End Sub
  8.  
  9. Private Sub Form_AfterUpdate()
  10.      frmDrawing.Refresh
  11. End Sub
  12.  
  13. 'mean while In a public module
  14.  
  15. Function GetLoadedForm(MyFormName, theform As Form) As Boolean
  16.     '  Determines if a form is loaded.
  17.     Const FORM_DESIGN = 0
  18.     Dim i As Integer
  19.     For i = 0 To Forms.count - 1
  20.         If Forms(i).FormName = MyFormName Then
  21.             If Forms(i).CurrentView <> FORM_DESIGN Then
  22.                 Set theform = Forms(i)
  23.                 GetLoadedForm = True
  24.                 Exit Function  '  Quit function once form has been found.
  25.             End If
  26.         End If
  27.     Next
  28.     GetLoadedForm = False
  29. End Function
Nov 5 '09 #5
MMcCarthy
14,534 Expert Mod 8TB
I may be wrong but if I am following you I think you need to change the variable scope of frmDrawing from Private to Public.
Nov 5 '09 #6
@msquared
I realize I did not make myself clear. The form variable and the sub routines are in a form called Drawing_Add. Its scope is only inside the form so it does not need to be public. I could have just defined it by Dim frmDrawing As Form_Drawings.
Nov 6 '09 #7
MMcCarthy
14,534 Expert Mod 8TB
OK I haven't time to check this at the moment but if I remember correctly the refresh only acts on unbound controls whereas you need the requery for bound controls. The refresh is essentially used to clear data from unbound controls and the requery is used to preform calculations on bound (and unbound) controls.

Having now reread the posts I think I know what your problem is. You're resetting the default value of the control and then trying to requery that value into an existing record. Default value only works on new records. Try passing the value directly into the control rather than resetting the default value.
Nov 8 '09 #8
NeoPa
32,556 Expert Mod 16PB
Actually, I think this is over-cooking the meal. AJ's post #4 is the simple solution. Refresh updates only the data for pre-existing records. A Requery will add new and remove old records from the list. This is required after a filter is applied (as the OP mentions belatedly in post #3).
Nov 8 '09 #9
MMcCarthy
14,534 Expert Mod 8TB
@NeoPa
I should have read them a third time I guess LOL! Thanks Ade.
Nov 9 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John Baker | last post by:
Hi: I have a Pop Up form that involves a main form and sub form. The sub form has the results of a query on the main form. I need to automatically perform exactly he same action that takes...
5
by: Andrew Chanter | last post by:
I have a situation where I am using an unbound dialog form to update data in an Access 2002 split back end / front end scenario. The data update is done via an ADO call (direct to the back end...
2
by: S. van Beek | last post by:
Dear reader, I have a strange situation. In a Form with a list box to search for a record in the form it self. The field in the list box is also available in the form. On an other...
2
by: Peter Oliphant | last post by:
I now have graphics being drawn in the Paint event of my form (yeah, and it's very cool). Problem was that it only updated any changes to these graphics when Paint was called. So, I then made it...
10
by: tasmisr | last post by:
This is an old problem,, but I never had it so bad like this before,, the events are refiring when clicking the Browser refresh button. In the Submit button in my webform, I capture the server side...
6
by: scott | last post by:
I guess this is a simple one but I can't seem to get it to work. I want to refresh an open form "onClose" of another. I have a Close button on a form which has User Details on it. If I update...
2
by: Robert | last post by:
I am trying to give the user dynamic search capabilities to select almost any record in the database from criteria they select. Everything seems to work except when I open the display form to...
12
by: martin1 | last post by:
All, is there window form refresh property? I try to set up window form refresh per minute. Thanks
5
by: tshad | last post by:
I have an interface I am using to get access to some of the objects on my form: a textbox (Status) and my statusbar (StatusBar). In my class, which is actually in another class from my form I have...
5
by: BlackBox | last post by:
I have a Listbox1 in the main form and I can add listbox1 items in the parent form. But when I close the parent form Listbox1 in the main form does not get refresh. I need to re-open the app. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.