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

Set variable

Hi
I want to be able to set a variable on the 'on got focus' event and use
that value in the 'on lost focus' event. This is because the on click event
enters a date into a field and I want to record what the old date was.
Is this possible or do I have to think along the lines of populating a
field in a temp table? I have to repeat this for other button objects on the
form.

Thanks in advance
Dave
Nov 13 '05 #1
5 5368
rkc
David wrote:
I want to be able to set a variable on the 'on got focus' event and use
that value in the 'on lost focus' event. This is because the on click event
enters a date into a field and I want to record what the old date was.
Is this possible or do I have to think along the lines of populating a
field in a temp table? I have to repeat this for other button objects on the
form.


Yes you can do it. OnFocus fires before OnClick.
You can also use On MouseDown.
Nov 13 '05 #2
One assumes there is some code which "enters a date into a field". In
the procedure where this code lives one could declare a static variable
and assign the old value of the textbox? to it just before the new date
is entered into the field.
You also may be able to use the OldValue of the control. I prefer my
own coding for this as I find that Access may be erratic about updating
OldValue (or perhaps I am just too lazy to learn when and how it is
updated).

Nov 13 '05 #3
I have tried setting a variable but utdoesnt seem to work, do u have the
code required to make it work?

thanks
Dave
"rkc" <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in message
news:fB******************@twister.nyroc.rr.com...
David wrote:
I want to be able to set a variable on the 'on got focus' event and
use that value in the 'on lost focus' event. This is because the on click
event enters a date into a field and I want to record what the old date
was.
Is this possible or do I have to think along the lines of populating
a field in a temp table? I have to repeat this for other button objects
on the form.


Yes you can do it. OnFocus fires before OnClick.
You can also use On MouseDown.

Nov 13 '05 #4
rkc
David wrote:
I have tried setting a variable but utdoesnt seem to work, do u have the
code required to make it work?


As Mr. Fairfield pointed out, the most logical place to save the old
value is in the same code block that changes it in the first place.

The option's for where you save it are endless. If you're going to
use the value in the same form it's saved in you can use a form level
variable. That is a variable declared at the beginning of the form's
module outside any methods there may be.

Multiple values can be stored in a form level collection using the
control name as the key.
Nov 13 '05 #5
David wrote:
Hi
I want to be able to set a variable on the 'on got focus' event and use
that value in the 'on lost focus' event. This is because the on click event
enters a date into a field and I want to record what the old date was.
Is this possible or do I have to think along the lines of populating a
field in a temp table? I have to repeat this for other button objects on the
form.

Thanks in advance
Dave

As Lyle said, you can get the OldValue ex: Me.Text0.OldValue
If Me.Text0 <> Me.Text0.OldValue
I think this only works with bound variables.

You can also enter something at the top of the form's code module to
declare the value. The form module may look something like this

Option Compare Database
Option Explicit
Dim varStorageVariable 'declares the variable globally for the form

Sub A
varStorageVariable = "David"
msgbox varStorageVariable
End Sub
Sub B
varStorageVariable = "Roebuck"
msgbox varStorageVariable
End Sub
Sub C
A 'call the routine
B 'call the routine
End Sub

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott | last post by:
I have an XML Document in a format like: <Variable name="Bob">ABCDEFG</Variable> <Variable name="Steve">QWERTYUI</Variable> <Variable name="John">POIUYTR</Variable> <Variable...
4
by: Frederik Sørensen | last post by:
I include a xslt stylesheet with variables for all the error messages in my system. <xsl:variable name="Banner_error_1"> errormessage 1 for banner </xsl:variable> <xsl:variable...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
10
by: Blaxer | last post by:
There is probably a really easy way to do this, so please forgive me but I would like to set the value of a variable from a variable, an example would be... function Calculate_Something(ByVal...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
3
by: rls03 | last post by:
I have the following which creates a variable containing a relative path where <xsl:value-of select="."/returns a portion of the filename: <xsl:variable...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
2
by: Florian Loitsch | last post by:
hi, What should be the output of the following code-snippet? === var x = "global"; function f() { var x = 0; eval("function x() { return false; }"); delete x; alert(x); }
37
by: minkoo.seo | last post by:
Hi. I've got a question on the differences and how to define static and class variables. AFAIK, class methods are the ones which receives the class itself as an argument, while static methods...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.