Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2008
    Posts
    5

    Trying to check a remote connection!

    Try to do 3 things.

    The 1st see if a database exists in a certain location:
    if it dose then connect.
    else show error message.

    The 2nd see if the database is open:
    if open the display a message to the users that they are going to get disconnected.
    pause for a length of time.
    then disconnect them from the database.

    The 3rd how to open the Database in exclusive mode.

    Below my code and possible placing of extra code.

    Writing with in Access 2003, and is a part of a unload download program.

    Public Const RemoteDatabase As String = "\\RemoteDatabase\RemoteDatabase.mdb"
    Public dbRemoteDatabase As New ADODB.Connection
    Public rsTableRemote01 As New ADODB.Recordset
    Public rsTableRemote02 As New ADODB.Recordset
    Public rsTableRemote03 As New ADODB.Recordset
    Public Const Table01 As String = "tblTable01"
    Public Const Table02 As String = "tblTable02"
    Public Const Table03 As String = "tblTable03"

    Function OpenRemoteDatabase1()
    If <try to see if the Database is there or not> = <true> then
    If<anyone is connected to it> = <true> then
    <Display message to Users that they are getting disconnected>
    <Pause state 60 seconds>
    <disconnect Users>
    End If
    If dbRemoteDatabase.State = 0 Then
    dbRemoteDatabase.Open "Provider = microsoft.jet.oledb.4.0;data source=" & RemoteDatabase

    rsTableRemote01.Open Table01, dbRemoteDatabase, adOpenDynamic, adLockOptimistic


    rsTableRemote02.Open Table02, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
    rsTableRemote03.Open Table03, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
    End If
    Else
    msgbox "Database not connected" & Chr(13) & Chr(10) & "Connect and re try" , vbCritical
    DoCmd.Close
    End If
    End Function

  2. #2
    Join Date
    Dec 2008
    Posts
    5

    Figured out part 1 any idea’s on rest

    Public sfso
    Set sfso = CreateObject("Scripting.FileSystemObject")
    If sfso.FileExists(RemoteDatabase) Then
    If dbRemoteDatabase.State = 0 Then
    dbRemoteDatabase.Open "Provider = microsoft.jet.oledb.4.0;data source=" & RemoteDatabase
    rsTableRemote01.Open Table01, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
    rsTableRemote02.Open Table02, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
    rsTableRemote03.Open Table03, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
    End If
    Else
    msgbox "Database not connected" & Chr(13) & Chr(10) & "Connect and re try" , vbCritical
    DoCmd.Close
    End If

Please reply to this thread with any new information or opinions.

Similar Threads

  1. connection performance
    By DanM in forum Programming
    Replies: 0
    Last Post: 08-24-2008, 08:25 AM
  2. Check Box issues
    By data123 in forum Forms
    Replies: 0
    Last Post: 01-03-2007, 03:21 PM
  3. check boxes
    By chiefmsb in forum Forms
    Replies: 1
    Last Post: 11-14-2006, 02:22 PM
  4. Connection to same DB
    By emilylu3 in forum Access
    Replies: 1
    Last Post: 12-30-2005, 09:59 AM
  5. connection to db
    By emilylu3 in forum Access
    Replies: 2
    Last Post: 12-29-2005, 01:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums