?
Solved

Launch Link Table Manager on Error

Posted on 2012-03-23
9
Medium Priority
?
869 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 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…
Suggested Courses

764 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