?
Solved

Launch Link Table Manager on Error

Posted on 2012-03-23
9
Medium Priority
?
871 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 58
ID: 37758791
<<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
ID: 37759010
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
ID: 37759026
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:fitaliano
ID: 37759044
Hi Jeff I just posted a new code, could you help with that?
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 2000 total points
ID: 37759097
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
ID: 37759762
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
ID: 37759766
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
ID: 37760804
ok
0
 
LVL 74

Expert Comment

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

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

840 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