UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Checking Linked Table Connected Or Not ?, Access 2013    
 
   
Sweetu
post May 16 2018, 08:35 AM
Post#1



Posts: 103
Joined: 20-September 16



How can we check if the linked(SQL) table is accessible or not & show warning msg,any VBA method?
Go to the top of the page
 
zaxbat
post May 16 2018, 09:32 AM
Post#2



Posts: 885
Joined: 26-January 06
From: .....the wiregrass (either you know or you don't)


There probably is standard routine for this....but you might just make a small function with error trapping and try to open, movelast, get recordcount, then close. If it does that without error....then ok. By the time you find the method or routine this function would already be built.
This post has been edited by zaxbat: May 16 2018, 09:34 AM

--------------------
Kindest regards, and Cheers!
ZAX

A picture is worth a thousand words and a zipped DB is worth a thousand pictures.
Oh, and....please don't disappear into the Twilight Zone.... Holler back with your results!
Go to the top of the page
 
kfield7
post May 16 2018, 12:05 PM
Post#3



Posts: 841
Joined: 12-November 03
From: Iowa Lot


I use

CODE
Function CheckLink(strTable As String) As Boolean
    
    ' Purpose:
    '     Checks the Link for the named table.
    '     Based on code from Ken Getz.
    '
    ' From Access 97 Developer's Handbook
    ' by Litwin, Getz and Gilbert. (Sybex)
    ' Copyright 1997. All Rights Reserved.
    '
    ' In:
    '    strTable - table to check
    ' Out:
    '    Return Value - True if successful; False otherwise
    ' History:
    '      Created 09/13/94 pel; Last Modified 07/10/96 pel

    Dim varRet As Variant
    
    On Error Resume Next

    ' Check for failure. If can't determine the name of
    ' the first field in the table, the link must be bad.
    varRet = CurrentDb.TableDefs(strTable).Fields(0).Name
    If Err <> 0 Then
        CheckLink = False
    Else
        CheckLink = True
    End If

End Function
Go to the top of the page
 
Sweetu
post May 16 2018, 03:42 PM
Post#4



Posts: 103
Joined: 20-September 16



please explain,how you're referring it ,on load or on open event?
Go to the top of the page
 
kfield7
post May 17 2018, 08:44 AM
Post#5



Posts: 841
Joined: 12-November 03
From: Iowa Lot




When my db opens, it opens a form, which on open calls code to check if the backend is linked, and if not, calls another function to prompt the user for the backend location and then relinks.

Go to the top of the page
 
Sweetu
post May 17 2018, 02:59 PM
Post#6



Posts: 103
Joined: 20-September 16



thanks
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    26th May 2018 - 05:15 AM