Hello,
I have the following two sub routines (please see below).
I need them to be combined in one function.
The subUpdatePageLinks must run before the subUpdateConnStr.
Also at present when the code runs it selects the dap in the database window making the database window visible even if it was hidden before which is no good.
I need the database window to remain hidden at all times and the object selected needs to be the first table in the hidden window.
Sub subUpdatePageLinks()
'
'Update the links for each data access page.
'
Dim aoDAP As AccessObject
Dim strLocation As String
Dim intPosition As Integer
'Retrieve the new path/location of the database.
intPosition = InStrRev(CurrentDb.Name, "\")
strLocation = Left$(CurrentDb.Name, intPosition)
'For each page...
For Each aoDAP In Application.CurrentProject.AllDataAccessPages
'Select the page.
DoCmd.SelectObject acDataAccessPage, aoDAP.Name, True
'Assign the new path/location to the page.
aoDAP.FullName = strLocation & aoDAP.Name & ".htm"
Next aoDAP
MsgBox "Links Updated."
End Sub
Sub subUpdateConnStr()
'
'This subroutine will update the ConnectionString property
'in each data access page within the current database.
'
Dim aoDAP As AccessObject
Dim dapObject As DataAccessPage
'Go through each data access page.
For Each aoDAP In Application.CurrentProject.AllDataAccessPages
'Open the current page.
DoCmd.OpenDataAccessPage aoDAP.Name, acDataAccessPageDesign
'Assign the current page to the data access page object.
Set dapObject = DataAccessPages(aoDAP.Name)
'Update the ConnectionString property of the current Page.
'CurrentDB.Name returns the path and file name to the database,
'that is, C:\Test\Northwind.mdb
dapObject.MSODSC.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & CurrentDb.Name
'Close the current page, saving the changes.
DoCmd.Close acDataAccessPage, dapObject.Name, acSaveYes
Next aoDAP
'Inform the user when the routine is complete.
MsgBox "Connection Strings Updated."
End Sub
I have the following two sub routines (please see below).
I need them to be combined in one function.
The subUpdatePageLinks must run before the subUpdateConnStr.
Also at present when the code runs it selects the dap in the database window making the database window visible even if it was hidden before which is no good.
I need the database window to remain hidden at all times and the object selected needs to be the first table in the hidden window.
Sub subUpdatePageLinks()
'
'Update the links for each data access page.
'
Dim aoDAP As AccessObject
Dim strLocation As String
Dim intPosition As Integer
'Retrieve the new path/location of the database.
intPosition = InStrRev(CurrentDb.Name, "\")
strLocation = Left$(CurrentDb.Name, intPosition)
'For each page...
For Each aoDAP In Application.CurrentProject.AllDataAccessPages
'Select the page.
DoCmd.SelectObject acDataAccessPage, aoDAP.Name, True
'Assign the new path/location to the page.
aoDAP.FullName = strLocation & aoDAP.Name & ".htm"
Next aoDAP
MsgBox "Links Updated."
End Sub
Sub subUpdateConnStr()
'
'This subroutine will update the ConnectionString property
'in each data access page within the current database.
'
Dim aoDAP As AccessObject
Dim dapObject As DataAccessPage
'Go through each data access page.
For Each aoDAP In Application.CurrentProject.AllDataAccessPages
'Open the current page.
DoCmd.OpenDataAccessPage aoDAP.Name, acDataAccessPageDesign
'Assign the current page to the data access page object.
Set dapObject = DataAccessPages(aoDAP.Name)
'Update the ConnectionString property of the current Page.
'CurrentDB.Name returns the path and file name to the database,
'that is, C:\Test\Northwind.mdb
dapObject.MSODSC.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & CurrentDb.Name
'Close the current page, saving the changes.
DoCmd.Close acDataAccessPage, dapObject.Name, acSaveYes
Next aoDAP
'Inform the user when the routine is complete.
MsgBox "Connection Strings Updated."
End Sub