Variable definition - Data type

fabioltj

Fabio Juliato
Local time
Yesterday, 20:58
Joined
Sep 8, 2005
Messages
15
Hello,
I would like to know what kind of Data Type I have to declare in order to share the value in a variable between process.
As example the code below:

Public Sub Form_Open(Cancel As Integer)
Dim data As Integer

DoCmd.openform "base"
data = Forms![base].Form![name]
DoCmd.Close
End Sub


Public Sub Command2_Click()

MsgBox ("The number is ") & data

End Sub


Thank you
 
Declare the variable at the top of your VB-project instead of inside a sub or function.

Example:
Code:
Option Compare Database
Option Explicit

Dim data As Integer

Public Sub Form_Open(Cancel As Integer)

DoCmd.openform "base"
data = Forms![base].Form![name]
DoCmd.Close
End Sub


Public Sub Command2_Click()

MsgBox ("The number is ") & data

End Sub
 

Users who are viewing this thread

Back
Top Bottom