473,386 Members | 1,715 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,386 software developers and data experts.

form Control auto updated from global variable

Is it possible to cause a contents of a variable defined in a Module as public, to be retrieved by a control(textbox) in the trailer of a bound single view Form.
Where desired data is not associated with the Table. bound to the Form
The variable's content is an application calculation.

Environment:
Windows Vista Ultimate, Access 2007

object: Module1
public varname as double

object: myform
Trailer section
textbox: display

failed attempt using :

textbox: Display
control source of: =Module1.varname

I realize I could programatically do this off some Event, I just looking for another way

--------------------------------------------------------------------------------
Feb 21 '08 #1
3 2603
Stewart Ross
2,545 Expert Mod 2GB
Is it possible to cause a contents of a variable defined in a Module as public, to be retrieved by a control(textbox) in the trailer of a bound single view Form.
Where desired data is not associated with the Table. bound to the Form
The variable's content is an application calculation.

Environment:
Windows Vista Ultimate, Access 2007

object: Module1
public varname as double

object: myform
Trailer section
textbox: display

failed attempt using :

textbox: Display
control source of: =Module1.varname

I realize I could programatically do this off some Event, I just looking for another way

--------------------------------------------------------------------------------
Hi Superspie. One way to get the value of a public (global) variable into a control is to write a public function to return its value and use a call to this function in the rowsource property.
Expand|Select|Wrap|Line Numbers
  1.  Public Function ReturnGlobal() as Double 
  2.      ReturnGlobal = Varname
  3. End Function
  4.  
You can then refer to this function in the rowsource property of your control (entering =ReturnGlobal() as the rowsource).

-Stewart
Feb 21 '08 #2
Thank you for the suggestion, however it yeilded only partial success. It appears that changes to a variable are not reflected in the control until a form refresh is done.

Side note: initial attemps using the function solution were unsuccessful, there appeared to be residual flags on the control which still caused the #name error to occur, until I deleted the control and created a new one.

I also tried to generalize the function also failed:

Public Function Rtnvar(varname) as variant
Rtnvar=varname
End Function

The above function would work in the debug Immeadiate window or in code, but not as Rowsource.
Feb 22 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Thank you for the suggestion, however it yeilded only partial success. It appears that changes to a variable are not reflected in the control until a form refresh is done...
Hi Superspie. The refresh issue relates to the control on the form, not the public variable, and is one that crops up frequently when using unbound controls. Access updates bound vaues when these change, but unbound values often have to be user-refreshed.

To refresh the value of the control alone - without refreshing the form - you can use the Requery method of the control itself. This can be done within the form code module using

Me.[controlname].requery

or from another code module by explicitly referring to the control

Forms(formname).Controls(controlname).Requery

-Stewart
Feb 22 '08 #4

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

Similar topics

5
by: lawrence | last post by:
I've this function, which is the method of a class. I'm posting the constructor of the class down below. For some reason, when I fill out a form and hit submit, I'm not getting any values. Can...
7
by: Saintor | last post by:
What I do now is I put a value in the tag property, and using the form_current event, I run through all controls properties until the ones with the required tag value are met. Sound OK in theory,...
1
by: Craig Addleman | last post by:
How do I use the pltcu unknown module to auto-load a return value from a select query? I'm trying to boost performance in our databases by preloading certain frequently-used variables. Ultimately...
19
by: Taras_96 | last post by:
Hi everyone, How do you detect that a form element has been changed? This thread: ...
4
by: kschneider | last post by:
Assume there's a form with it's action attribute all set to post to a URL, but without a submit control. Form submission is done via a link and I want to prevent the classic "double submit"....
2
by: David W. Fenton | last post by:
I think at various times we've all encountered this problem: A subform is on a main form. From the code of the main form we refer to some property of/control on the child form thus: ...
2
by: Mike | last post by:
Hello, Ok I have 2 classes in my project, one is the main form and one is a connection class, at a certain event on my main form a new instance is made of the connection class, and a reference...
12
by: Rob | last post by:
Let's say you open Form1 that contains TabControl1 There are several tabs on TabControl1 Now you open a new Form2 that contains a User Control How can you determine the Selected tab in Form1...
1
by: superspie | last post by:
Is it possible to cause a contents of a variable defined in a Module as public, to be retrieved by a control(textbox) in the trailer of a bound single view Form. Where desired data is not...
5
by: ChipR | last post by:
Question: Can I set a form's variable from another form? Details of my problem: In my Form1, I have Option Compare Database Option Explicit 'whether each tab has been updated, so they...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.