Results 1 to 8 of 8

Thread: [RESOLVED] MDI quick help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    245

    Resolved [RESOLVED] MDI quick help

    hey all,
    I have a simple question i hope that someone could be kind enough to help me with. I have an MDI form that each child connects to the same datasource and such. How could I implement the connection within the parent window after it opens to where each child is feeding off of that one connection rather than each child opening a connection each time they are accessed? Thanks alot.

    tibor

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: MDI quick help

    Put your connection code in a Sub in a module using Public variables.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    245

    Re: MDI quick help

    Ok I've gotten this far now but when my child pages call upon my connection object it says varaible not defined. It is in a module with public variables.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: MDI quick help

    I just whipped up a quick MDI application, put a public variable in a module, and was able to retrieve the contents of the public variable no matter how many child windows I added.

    How are you doing it?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    245

    Re: MDI quick help

    Well i am sure i am missing one tiny detail but heres the code

    for the Module
    VB Code:
    1. Public Sub Connect()
    2.  
    3. Dim oConn As New Connection
    4.  
    5. oConn.Properties("Prompt") = adPromptAlways
    6. oConn.Open "Driver={SQL Server};Server=;DataBase=mas500_app;password=;User ID=sa"
    7.  
    8. End Sub

    for the child page

    VB Code:
    1. ors.Open strsql, oConn, adOpenDynamic, adLockOptimistic

    it says oConn not defined, so what do i put in its place?

  6. #6

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: MDI quick help

    Yes, you are missing one tiny thing. You need to make your connection object Public
    VB Code:
    1. 'in a module
    2.  
    3. Option Explicit
    4.  
    5. Public oConn As ADODB.Connection
    6.  
    7. Public Sub Connect()
    8.  
    9. Set oConn = New ADODB.Connection
    10.  
    11. oConn.Properties("Prompt") = adPromptAlways
    12. oConn.Open "Driver={SQL Server};Server=;DataBase=mas500_app;password=;User ID=sa"
    13.  
    14. End Sub
    Now oConn will be available as a connection object througout your project.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    245

    Re: MDI quick help

    Sweet thanks so much for the help. First module I've even tried so it was all way new to me. thanks so much for your patience and help.
    tibor

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