Results 1 to 2 of 2

Thread: Declaring global variables

  1. #1
    Guest

    Post


    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 & "'"

  2. #2
    Junior Member
    Join Date
    Nov 1999
    Location
    Muscatine, Iowa, USA
    Posts
    18

    Post

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width