Results 1 to 3 of 3

Thread: global declartion of recordsets

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    Angry

    I have run in a bit of a problem because of this
    Dim DB As Database
    Dim rs As Recordset
    Dim Apps As FileSystemObject
    Set Apps = CreateObject("Scripting.FileSystemObject")
    'set db location
    Set DB = OpenDatabase(App.Path & "\configuration.mdb")
    'Open the Contact table
    Set rs = DB.OpenRecordset("SELECT netVESPAWeb.*, ISDefine.SetPreProccessor, altCarriers.Carrier FROM (ISDefine INNER JOIN netVESPAWeb ON ISDefine.ID = netVESPAWeb.ISPreProccessorType) INNER JOIN altCarriers ON netVESPAWeb.SetCarriers = altCarriers.ID", dbOpenDynaset)

    I cannot decalre this globally, or can i any help please, i'm using mutiple functions that follow the record set and need them globally visible..?

    Thanks in advance

  2. #2
    Guest

    Thumbs up Yeah don't understand why MS did this but

    Ok MS use of Global variables is damn stupid....there got that off my chest....

    Back to the question....

    If you want to declare Global variables do it in a .bas routine. Generally add one to the project, and declare your globals in the general section at the top

    Option Explict
    Global rMyRecordset as Recordset
    Global dbMyDatabase as Database
    Private sPath as string

    Forgot the name of the procedure to add to this but something like Sub Main....try it anyway

    In this procedure

    set all your global variables.

    Now go to vbs drop down menu and select Project->Properties and the first tab.

    Now on this window there is a drop down combo box called something like start or whatever, (sorry don't have vb at this site so am flying blind here.

    Anyway it's the combo with the projects first form name in it. Click the down arrow and select Sub Main.

    Ok this will initialise and declare your globals first when the projext/exe start. Call your main form or whatever from within Sub Main.

    Hope that helps

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Jethro's advice about creating global variables in a module is correct, but there is absolutely no need to use Sub Main or have it as your project's Statup Object. The Startup Object can reamin what ever it is today and it will work just fine.

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