Solved

Launch Link Table Manager on Error

Posted on 2012-03-23
9
867 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 57
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

749 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