PDA

Click to See Complete Forum and Search --> : Declaring global variables


Jan 26th, 2000, 06:47 PM
Hi,
I tried passing a global variable in the general declaration section of a module in Form1 so that a recordset in a second module in Form2 could read the variable. Whenever, Form2 is loaded to read the below SQL syntax in the VB code, it comes with an error message "variable not defined" with SQLconnect highlighted. Any help on this problem would be appreciated. Thanks

Albert.


rsDat.Open SQLconnect,CnData, dbOpenDynamic


SQLconnect = "Select OrderID,OrderDate from Employees, Orders Where Employees.[EmployeeID] = Orders.[EmployeeID]" _
& " And Lastname='" & Combo1.Text & "'"

jbuck
Jan 26th, 2000, 09:52 PM
Hi Albert,
Declare the variables in your "module.bas" program like below.

Public GlobalCaseNbr As String
Public GlobalPartNbr As String
Public GlobalMedRecNbr As String
Public GlobalDate As String
Public GlobalFound As String
Public AddRespString As String

Public frmMain As frmMain
Sub Main()

frmSplash.Show vbModal ' Show the Splash Screen
If SplashOk Then
Unload frmSplash
End If

Then the variables will be available through out the whole application.
Jim