setting CurrentProject.Connection in VBA

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ol!v!é

    #1

    setting CurrentProject.Connection in VBA

    I have an ADP Project in MsAccess XP, with an MSSQL-backand (MSDE).

    I would like to set the Connection of the project from VBA, so all the
    forms and reports can use it. Normally, I set this through the
    File->Connection menu, but if the network connection falls away for a
    moment, I have to reconnect manually. I would like to reconnect
    automatically with VBA.

    I've tried using CurrentProject. Connection.Open and
    CurrentProject. Connection.Conn ectionstring, but that didn't work well.

    Thanks in advance,

    Ol!v!é
  • Lyle Fairfield

    #2
    Re: setting CurrentProject. Connection in VBA

    Ol!v!é wrote:[color=blue]
    > I have an ADP Project in MsAccess XP, with an MSSQL-backand (MSDE).
    >
    > I would like to set the Connection of the project from VBA, so all the
    > forms and reports can use it. Normally, I set this through the
    > File->Connection menu, but if the network connection falls away for a
    > moment, I have to reconnect manually. I would like to reconnect
    > automatically with VBA.
    >
    > I've tried using CurrentProject. Connection.Open and
    > CurrentProject. Connection.Conn ectionstring, but that didn't work well.
    >
    > Thanks in advance,
    >
    > Ol!v!é[/color]

    Public Sub LetConnectionSt ring()
    With CurrentProject
    If Not .IsConnected Then
    .OpenConnection ("PROVIDER=SQLO LEDB.1;" _
    & "INTEGRATED SECURITY=SSPI;" _
    & "PERSIST SECURITY INFO=FALSE;" _
    & "INITIAL CATALOG=FFDBAES O;" _
    & "DATA SOURCE=ITSERVER 9;" _
    & "Use Procedure for Prepare=1;" _
    & "Auto Translate=True" )
    End If
    End With
    End Sub


    --
    Lyle
    --

    Comment

    • Ol!v!é

      #3
      Re: setting CurrentProject. Connection in VBA

      Lyle Fairfield wrote:[color=blue]
      >
      > Public Sub LetConnectionSt ring()
      > With CurrentProject
      > If Not .IsConnected Then
      > .OpenConnection ("PROVIDER=SQLO LEDB.1;" _
      > & "INTEGRATED SECURITY=SSPI;" _
      > & "PERSIST SECURITY INFO=FALSE;" _
      > & "INITIAL CATALOG=FFDBAES O;" _
      > & "DATA SOURCE=ITSERVER 9;" _
      > & "Use Procedure for Prepare=1;" _
      > & "Auto Translate=True" )
      > End If
      > End With
      > End Sub
      >
      >
      > --
      > Lyle
      > --[/color]
      Thanks, it works great!

      Ol!v!é

      Comment

      • pietlinden@hotmail.com

        #4
        Re: setting CurrentProject. Connection in VBA

        Maybe this is a bad place to put this, but...

        so what's are good books on ADO (and maybe ADO.NET)?

        I have a copy of Database Access with VB.Net and it's just godawful.
        The author doesn't do anything helpful like give a full code listing in
        an index or anything like that, so it's really hard to learn unless
        you're typing the whole time. fine and dandy, but hardly portable...

        Comment

        Working...