Hi Ofer,
If Right(ref.FullPath, 3) = "mdb" Or Right(ref.FullPath, 3) = "mde" Then
Have you tested your new procedure with .mde files? I think you can only
change references programmatically in .mdb files.
Thanks for marking my response as an answer!
Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
:
I knew how to do it on the local mdb, but I couldn't figure it how to do it
in a remote mdb.
Any that the code if any one will need it, thanks for your help
Public Function Set_Ref(MDBNameLocation As String, New_Path As String) As
Boolean
On Error GoTo err_Set_Ref
Dim strMessage As String
Dim strDbName As String
Dim refItem As Reference
Dim str_tmpRef As String
Dim appAccess As Access.Application
Dim ref As Reference
Set appAccess = New Access.Application
appAccess.OpenCurrentDatabase MDBNameLocation
Set ref = References!Access
For Each ref In appAccess.References
If Right(ref.FullPath, 3) = "mdb" Or Right(ref.FullPath, 3) = "mde" Then
str_tmpRef = ref.Name
strDbName = Mid(ref.FullPath, InStrRev(ref.FullPath, "\") + 1)
appAccess.References.Remove ref
appAccess.References.AddFromFile New_Path & "\" & strDbName
Set_Ref = True
End If
Next ref
appAccess.CloseCurrentDatabase
Exit Function
Exit_Set_Ref:
Set_Ref = False
Exit Function
err_Set_Ref:
MsgBox Err & ": " & Err.Description
Resume Exit_Set_Ref
End Function
--
I hope that helped
Good luck
_______________________________________________
:
Hi Ofer,
I think you can use a variation of the code shown in this KB article:
http://support.microsoft.com/?id=323203
See the section titled "Using Code to Refresh the References". You would,
of course, substitute your own path instead of using s = r1.FullPath
Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
:
In MDB1 I have reference to MDB2 and MDB3 ... MDB10, all are located in
"c:\Dev\" directory.
What I need is, using code in MDB20 to change the location of the reference
in MDB1, to MDB2 and MDB3 ...MDB10 to "c:\QA\" directory.
The idea is, when I want to move a new version from DEV to QA or to
Production, I want to give a location of all the mdb's, and with a click on a
button the reference location will be changed to the new location
I hope I was clear about my intentions, thanks for your help