Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2008
    Posts
    1

    Unanswered: Generate Connection Fail Message

    I am running a SQLServer DB on a server.
    I have an MSAccess front-end with some linked tables (via an ODBC connection).

    When a user is not connected to the internet and they try to access a form or report that requires access to the linked tables an ODBC connection error pops up and my users get cranky.

    Is there a way to create the following:

    Iif - "no odbc connection"
    Then - "msg user & stop macro"
    Else - "open form or report"?

    Thanks in advance for your help.

    Ryan

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    You should be able to trap for it. This works for me:

    Code:
    Err_Handler:
      Select Case Err
        Case -2147467259    'not connected
          MsgBox "Not connected to network"
          DoCmd.Quit
    Paul

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    See if this bit of code helps in any way: http://www.dbforums.com/showpost.php...3&postcount=22
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Thumbs up openconnection

    You should be able to use itellisence
    after you have set your connenctionstring

    Code:
    set objConnection=Server.CreateObject("ADODB.Connection")
    objConnection.Provider="Microsoft.Jet.OLEDB.4.0"
    objConnection.Open "c:/webdata/northwind.mdb"
    you can use

    Code:
    If (objConnection.State = adStateClosed) Then '
       msgbox "Connection object is closed",vbokonly + vbexclamationmark,"No Connection"
    exit sub
    End If

    Code:
    Constant              Value           Description 
    adStateClosed         0                The object is closed 
    adStateOpen           1                The object is open 
    adStateConnecting   2                The object is connecting 
    adStateExecuting     4                The object is executing a command 
    adStateFetching      8                 The rows of the object are being retrieved
    Greetz Marvels -^.^-
    Developments : VB4 Through .Net; Basic; DOS ; CNC ; Sinclair
    Databases : SQL Server Through 2005; Access 3 Through 2003 ; Oracle 8 & 9.i ;
    OS : Win 3.11 Through XP ; NortonComander ; DOS

Posting Permissions

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