Solved

Launch Link Table Manager on Error

Posted on 2012-03-23
9
863 Views
Last Modified: 2012-03-24
I have the following code

On Error GoTo Err_Form_Load

bla bla bla...

Exit_Form_Load:
    Exit Sub

Err_Form_Load:
   
    RunCommand acCmdLinkedTableManager


Instead of executing LinkedTableManager, I get the message that the path cannot be found.


Do you guys know why?
0
Comment
Question by:fitaliano
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
<<Do you guys know why?>>

 Because your in the middle of an error handler I believe and haven't issued a resume.

 None of the wizard code nor linked table manager, add-ins, etc will run if your code is not in a normal running state.

 You can double check that just by moving the statement up into the top of the procedure as the first executable line as a test.

 If it works there, then it's the error handler.  If not, something else is going on.

Jim.
0
 

Author Comment

by:fitaliano
Comment Utility
Never say never in technology.

If I use the On Error event, it works!

This the code I used, the only thing would be to automatically close or re-start the splash screen after I get the deafult error message the the path is not correct.  Any help here?

Private Sub Form_Error(DataErr As Integer, Response As Integer)

On Error GoTo Err_Form

MsgBox ("Your Application is not linked to the BVR database. In the next window, check 'Alway prompt for a new window' and 'Select All'. Ignore the message about the inccorrect path at the end You must re-launch the Application after refreshing the links")
RunCommand acCmdLinkedTableManager

Form_Error:

Exit_Err_Form:
DoCmd.OpenForm ("00_F_Splash")
    Exit Sub

Err_Form:
    MsgBox Err.Description
    Resume Exit_Err_Form

End Sub
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
1. Also your syntax is a bit off:
sb:     Docmd.Runcommand acCmdLinkedTableManager


2. Is this just an example, or do you really want to run the Linked table manager on *Any* error

You may want to add something like this:

If err.Number n Then
    Docmd.Runcommand acCmdLinkedTableManager
else
    msgbox err.Number & " Some Message"
end if


;-)

Jeff
0
 

Author Comment

by:fitaliano
Comment Utility
Hi Jeff I just posted a new code, could you help with that?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 26

Accepted Solution

by:
Nick67 earned 500 total points
Comment Utility
Let me respond by going sideways
Why would you want to do this RunCommand acCmdLinkedTableManager
anyway?

It is complicated to wrap your head around, but the stuff that the linked table manager can do can also be done in VBA code.  The place to check if all your linked tables are properly linked and refreshed is in the (optional) AutoExec routine

Here's a sample of that type of code
Function Refresh_Table_Link()
On Error GoTo myerr
Dim TD As TableDef
' a string to hold the TableDef's new connection string
Dim linkstring As String
'a number for InStr to return if it finds a linked table
Dim intSubStringLoc As Integer

For Each TD In CurrentDb.TableDefs
    If Len(TD.Connect) > 0 Then 'it has a connection string
        intSubStringLoc = InStr(TD.Connect, "DATABASE=MyDataBase") 'look for the part that says it is linked to my SQL Server
        'substitute something appropriate for your stuff
        
        If intSubStringLoc > 0 Then 'if it is a linked table
            linkstring = "" '<---------------The appropriate ODBC Linkstring goes here
            If TD.Connect <> linkstring Then
                TD.Connect = linkstring
            End If
            TD.RefreshLink
        End If
    End If
Next

Exit Function

myerr:
MsgBox TD.Name
Resume Next

End Function

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
Nick in some cases they may want to only refresh certain tables, or in others the may want to change the location of the BE.

...so the just may want to open the dialog box...
0
 
LVL 26

Expert Comment

by:Nick67
Comment Utility
Certainly possible, but since the code posted was for form error, I get the feeling we're looking at catching a form load failure.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
ok
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
Yeah, I did not think of it form that angle...
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now