473,396 Members | 2,037 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,396 software developers and data experts.

How to declare a global integer in VBA?

Hi,
I wrote a function in VBA which is called from an SQL proccess.
Some of the iterations of the function don't work properly so I'm trying to fix these conditions.
The bottom line is, I'm trying to compare an integer from one iteration of the function to the following one, but whenever the function gets called again it erases the integer.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "UPDATE TableName_
  2.  SET TableName.Time = RoundSeconds(TableName.Time)"
  3.  
  4.  
  5. Public Function RoundSeconds(varTime As Variant)
  6. .
  7. .
  8. .
  9. End Function
  10.  
How can I save data from within the function to compare in the next iteration?

Thanks in advance,
Izhar
Jun 6 '10 #1
4 2920
ADezii
8,834 Expert 8TB
@izharmel
  1. Declare the Variable as Static within the Function whereby it will retain its Value between successive Calls, as in:
    Expand|Select|Wrap|Line Numbers
    1. Static sintYaDaYaDa As Integer
  2. Declare the Variable as Public within a Standard Code Module, in which case it will retain its Value until the Application Terminates, as in:
    Expand|Select|Wrap|Line Numbers
    1. Public gintYaDaYaDa As Integer
Jun 6 '10 #2
Thank you,
You helped me a lot
Jun 9 '10 #3
ADezii,

Good Answer

Thank You...

(Medo)
Jun 9 '10 #4
ADezii
8,834 Expert 8TB
@izharmel
You are quite welcome.
Jun 9 '10 #5

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

Similar topics

5
by: NotGiven | last post by:
I have an file I call using: require_once() In this file I have variables I'd like to use in the calling page and functions called by that page. How can I do this? example:
6
by: rick | last post by:
Noob problem. I prefer to keep all my scripts in an external '.js' file. I am currently loading the external '.js' file from the header. Problem is I would like to declare a global variable in the...
1
by: Ron | last post by:
Hello, I need to create/instantiate a global class library project so that 2 EXE's can write to the same class library form in the same instance of the class libary. I am thinking something...
1
by: Gandham | last post by:
hi i am sujatha how to declare global varibles in .net 2005
9
by: johnlim20088 | last post by:
Hi, Hi, currently I developing an application in C# NET, let say i have a page call viewrecord.aspx, in this page, i have a global variables declared before the page_Load, so all function can...
0
by: sgueder | last post by:
Hi there, hope anybody can help me: I want to create a temporary table, want to fill that table with data and finally I want to use that table as my base-table for running some selects on it...
1
by: Konstantinos Pachopoulos | last post by:
Hi, i had posted earlier for not being able to declare global vars. No i followed the suggestions and created a class, but still the vars do not seem to have a global scope. I have tried pretty...
1
by: lokesh kumar | last post by:
where and how to declare global variable in vb2005 ? EggHeadCafe - .NET Developer Portal of Choice http://www.eggheadcafe.com
3
by: Lennart | last post by:
Any thoughts on the following scenario anyone? During a performance test I discovered that the application asked one specific query extremely often. It turned out that this particular query...
3
by: sravik | last post by:
how and where to declare global variables in C#. Like Conection strings and some file paths etc.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.