Solved

Launch Link Table Manager on Error

Posted on 2012-03-23
9
865 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
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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

786 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