ForcedToUseIt
Registered User.
- Local time
- Today, 14:10
- Joined
- Jul 25, 2004
- Messages
- 34
Hi all,
I had this problem happen to some of my users when I released my front end .mdb to about 50 users which meant that i had to go to them and relink the references manually on about 15 computers!
I found this article in the MSDN knowledge base and tried the code to fixit, but it didnt work since it is for Access 97 and I'm using Access 2003 with a .mdb file with Access 2000 file format as the default.
Can anyone tell me how it is best to resolve this problem? Perhaps the code in the article only needs some small adjustments to work or something. The stange thing is that it runs fine but doesnt fix the problem.
I have a feeling that it is the Call command at the bottom of the code that is not doing it's job...
Here is the code for your viewing:
I had this problem happen to some of my users when I released my front end .mdb to about 50 users which meant that i had to go to them and relink the references manually on about 15 computers!
I found this article in the MSDN knowledge base and tried the code to fixit, but it didnt work since it is for Access 97 and I'm using Access 2003 with a .mdb file with Access 2000 file format as the default.
Can anyone tell me how it is best to resolve this problem? Perhaps the code in the article only needs some small adjustments to work or something. The stange thing is that it runs fine but doesnt fix the problem.
I have a feeling that it is the Call command at the bottom of the code that is not doing it's job...
Here is the code for your viewing:
Code:
Function CheckRefs()
Dim db As Database, rs As Recordset
Dim x
Set db = CurrentDb
On Error Resume Next
' Run the query qryTestRefs you created and trap for an error.
Set rs = db.OpenRecordset("qryTestRefs", dbOpenDynaset)
' The if statement below checks for error 3075. If it encounters the
' error, it informs the user that it needs to fix the application.
' Error 3075 is the following:
' "Function isn't available in expressions in query expression..."
' Note: This function only checks for the error 3075. If you want it to
' check for other errors, you can modify the If statement. To have
' it check for any error, you can change it to the following:
' If Err.Number <> 0
If Err.Number = 3075 Then
MsgBox "This application has detected newer versions " _
& "of required files on your computer. " _
& "It may take several minutes to recompile " _
& "this application."
Err.Clear
FixUpRefs
End If
End Function
Sub FixUpRefs()
Dim loRef As Access.Reference
Dim intCount As Integer
Dim intX As Integer
Dim blnBroke As Boolean
Dim strPath As String
On Error Resume Next
'Count the number of references in the database
intCount = Access.References.Count
'Loop through each reference in the database
'and determine if the reference is broken.
'If it is broken, remove the Reference and add it back.
For intX = intCount To 1 Step -1
Set loRef = Access.References(intX)
With loRef
blnBroke = .IsBroken
If blnBroke = True Or Err <> 0 Then
strPath = .FullPath
With Access.References
.Remove loRef
.AddFromFile strPath
End With
End If
End With
Next
Set loRef = Nothing
' Call a hidden SysCmd to automatically compile/save all modules.
Call SysCmd(504, 16483)
End Sub