Access VBA Subroutine limitations

stoka

Getting Better
Local time
Today, 07:42
Joined
Jan 22, 2007
Messages
23
In general Subroutines do not return values, only functions. However, the value of a public variable can be changed within a sub. I have read that Access Subs cannot return values but I wonder if the above method works. I have a variable declared at the very top of the form code page (not a module) and in 5 different BeforeUpdate events for 5 different controls I recalcualte the total of the values of these 5 controls, trying to verify that by the time the input is completed that at least ONE of them has a value...but the total value does not come out and display on the form...only if i put = val(controll1) + val(control2) + ..... does it display....is this because truly you can't change the value of dblValue inside subs and have the value be retained etc.
 
A variable declared in the general declarations section of a form module should be able to hold a value throughout the lifetime of the form. What does your declaration look like and what does the code in the subs look like? I assume that you have already ensured that you didn't accidentally dim the variable in the procedure as well as in the declarations section.
 

Users who are viewing this thread

Back
Top Bottom