View Full Version : Variable definition - Data type


fabioltj
12-07-2005, 07:42 AM
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

seth_belgium
12-07-2005, 08:17 AM
Declare the variable at the top of your VB-project instead of inside a sub or function.

Example:

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