Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / January 2008

Tip: Looking for answers? Try searching our database.

Start DB when not connected to network

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SAP2 - 15 Jan 2008 13:37 GMT
Scenario:
Currently calling the function SynchronizeDBs in the On Open Event of the
Start-up form.  The function is called out as follows:
=SynchronizeDBs("C:\Documents and Settings\...\IDB
HubR1.mdb","\\ww007\...IDB Hub.mdb",1)

The function code is:
Function SynchronizeDBs(strDBName As String, strSyncTargetDB As String, _
intSync As Integer)

Dim dbs As DAO.Database

Set dbs = DBEngine(0).OpenDatabase(strDBName)

Select Case intSync
Case 1 'Synchronize replicas (bidirectional exchange).
dbs.Synchronize strSyncTargetDB, dbRepImpExpChanges
Case 2 'Synchronize replicas (Export changes).
dbs.Synchronize strSyncTargetDB, dbRepExportChanges
Case 3 'Synchronize replicas (Import changes).
dbs.Synchronize strSyncTargetDB, dbRepImportChanges
Case 4 'Synchronize replicas (Internet).
dbs.Synchronize strSyncTargetDB, dbRepSyncInternet
End Select

dbs.Close
End Function

So in this case it is performing a direct bidirectional exchange when the DB
starts up.

Problem (what I am trying to solve):
If the DB is not connected to the server it shows a runtime error and will
only let me end or debug.  The DB start-form will not run.

I would like for the remote users to be able to enter the DB even if not
connected.  So I would like for the function to run, but on error continue to
open the DB normally.  For me that would ensure that when they are connected
the information exchange is intact, but when not connected they can still use
the DB without any interruption.

I hope this is clear.  I am not an access expert or a vba expert so
suggestions of an alternative to get to the end would be helpful also.  Thank
you in advance.
Douglas J. Steele - 15 Jan 2008 14:28 GMT
The simplest approach would be to prompt the user.

Function SynchronizeDBs(strDBName As String, strSyncTargetDB As String, _
 intSync As Integer)

Dim dbs As DAO.Database

 if MsgBox("Are you connected to the network?", _
   vbYesNo + vbQuestion) = vbYes Then

  Set dbs = DBEngine(0).OpenDatabase(strDBName)

  Select Case intSync
    Case 1 'Synchronize replicas (bidirectional exchange).
      dbs.Synchronize strSyncTargetDB, dbRepImpExpChanges
    Case 2 'Synchronize replicas (Export changes).
      dbs.Synchronize strSyncTargetDB, dbRepExportChanges
    Case 3 'Synchronize replicas (Import changes).
      dbs.Synchronize strSyncTargetDB, dbRepImportChanges
    Case 4 'Synchronize replicas (Internet).
      dbs.Synchronize strSyncTargetDB, dbRepSyncInternet
  End Select

  dbs.Close
 End If

End Function

A more sophisticated approach would be to use code like what Randy Birch has
at http://vbnet.mvps.org/code/network/isnetworkalive.htm to detect whether
they're connected. (Of course, it's possible that they could be connected,
but to the wrong network...)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Scenario:
> Currently calling the function SynchronizeDBs in the On Open Event of the
[quoted text clipped - 45 lines]
> Thank
> you in advance.
SAP2 - 15 Jan 2008 15:49 GMT
Douglas,
Thank you!!  Your addition was exactly what I needed.  Sometimes the DB will
run really slow through VPN so the option is a perfect idea.

I saw Randy Birch's code during my search.  I am not that sophisticated.

Thanks again.

> The simplest approach would be to prompt the user.
>
[quoted text clipped - 78 lines]
> > Thank
> > you in advance.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.