Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2004
    Posts
    64

    Unanswered: Creating a public connection

    I have a few connections to the same back end. Is there a way of declaring the connection publicly so I can call the connection from the forms instead of creating it each time?

  2. #2
    Join Date
    Mar 2002
    Location
    Bielefeld, Germany
    Posts
    69
    I'm not exactly sure if I understand you correctly, but however

    You can put something like this in a module:

    public myConn1 as adodb.connection

    and then initialize myConn1 when first needed

    public sub initConn()
    set myConn1 = new adodb.connection
    myConn1.ConnectionString="whateverYouNeedHere"
    end sub

    and on shutdown destroy myConn with the usual set myConn1 = nothing.

  3. #3
    Join Date
    Jul 2004
    Posts
    64
    ahh.. I think that will do it.. Thank you!

  4. #4
    Join Date
    Jul 2004
    Posts
    64
    One more question:

    I have the following statement that opens a recordset:

    Code:
     .Open "Select * from tblCaseUpdates WHERE description LIKE'" & "*" & mySearchStr & "*" &  "'"", CurrentProject.Connection, adOpenKeyset, adLockOptimistic"
    For some reason, this is not working, as I figure I have my syntax wrong for the LIKE operator. If I remove the WHERE condition the SQL runs fine.

  5. #5
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    I always use the application's connection for ADO. forexample:
    Code:
     
    	Dim ADOCon As ADODB.Connection
    	Set ADOCon = Application.CurrentProject.Connection
    	ADOCon.Execute (SQLStr)
    It also derrives user security and rights of the database.
    ghozy.

  6. #6
    Join Date
    Jul 2004
    Posts
    64
    Thanks, I will remember that.. Any ideas on the variable problem?

  7. #7
    Join Date
    Mar 2002
    Location
    Bielefeld, Germany
    Posts
    69
    Should be

    .Open "Select * from tblCaseUpdates WHERE description LIKE '" & "*" & mySearchStr & "*" & "'", CurrentProject.Connection, adOpenKeyset, adLockOptimistic

Posting Permissions

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