Help in understanding variables

  • Thread starter Thread starter ZBC
  • Start date Start date
Z

ZBC

I am using Access 2000 and have done on VB6 coding (a couple of years ago).
In working with my current project and trying to understand the best way
to do things, I have a couple of questions:


1) When I am in the process of working on the design of a form and
switch to 'code' , can I declare variables and use them like I did in VB6?

2) When I use an expression like:
Me!NewCount = Nz(Me!OldCount, 0) + Nz(Me!Changes, 0)
I am not sure I know what 'variables' ?? I have available to us ... In
other works, I don't understand the use of 'Me!<something>
I have used it previously because someone told the expression.
I could not find anything in Help.

I hope these are not too stupid of questions!
 
Yes, you can declare variables using the same DataTypes as with VB:

Dim strName As String
Dim varNames() As Variant
Dim strNames() As String
Dim lngID As Long

You can declare them with Public scope (which is like Global), if you do so
in the General Declarations section of a publicly available code module
(like a Standard Module), Private scope (if they're only used in the local
function/sub) ... you can also declare them as Public in a FORM module, but
that carries with it some strange behavior, since you'll only be able to use
the variable when the form is open

The "Me" keyword is a shortcut to the currently active object (form or
report). If you're working on frmCustomer and, in the code module, type
this:

Me.ctlCustomer.Name

You are referring to a control named "ctlCustomer", and specifically to the
property of that control named "Name"

The expression you included is not referencing any variables, however it is
doing this (in English)

Set the value of a field/control named "NewCount" to equal the sum of (the
value of a field/control named OldCount) + (the value of a field/control
named Changes) ... additionally, if either OldCount or Changes Is Null, them
change them to = 0 so the addition process doesn't fail




I am using Access 2000 and have done on VB6 coding (a couple of years ago).
In working with my current project and trying to understand the best way to
do things, I have a couple of questions:


1) When I am in the process of working on the design of a form and switch
to 'code' , can I declare variables and use them like I did in VB6?

2) When I use an expression like:
Me!NewCount = Nz(Me!OldCount, 0) + Nz(Me!Changes, 0)
I am not sure I know what 'variables' ?? I have available to us ... In other
works, I don't understand the use of 'Me!<something>
I have used it previously because someone told the expression.
I could not find anything in Help.

I hope these are not too stupid of questions!
 
Scott,
I cannot tell you how much I appreciate you taking the time and effort
to explain this as you did ...
THANK YOU VERY MUCH!
Bob
 
Back
Top