pt*****@aol.com (Ptbrady) wrote in
news:20***************************@mb-m14.aol.com:
What does "ByVal" mean? I couldn't find it in the Access help
messages. Here is the first line of a function:
Public Function GetAge(ByVal pvarBirthdate As Variant, ByVal
pvarAgeCalcDate As Variant) As Long
Why is ByVal needed? I've written other functions that don't
have it, that is, they would look like:
Public Function GetAge(pvarBirthdate As Variant,
pvarAgeCalcDate As Variant) As Long
Thanks in advance. Pete
When you pass a parameter to a procedure or function Access can
either simply point to the existing variable or make a local copy
of the contents (value) of the variable for the procedure to use.
Pointing to the variable allows the programmer to modify the
contents of the variable, (this is the way cancel works in the
beforeupdate sub),ByValue makes a separate copy of the variable
for use in the sub, so that you cannot change the value of the
variable in the calling procedure.
Including the ByVal is good programming practice that shows that
you do not want to play with the calling procedure's variable.
--
Bob Quintal
PA is y I've altered my email address.