Here two examples, one for the forms and the other for reports. There are
lot of scrap in these because I usually edit them on the fly for any
particular purpose:
' Forms.
Public Function Travail_Formes_RecordSourceQualifier_dbo()
Dim bASauvegarder As Boolean
bASauvegarder = False ' Set to True if the form must be saved at the
end of the process.
Dim i As Integer
i = 0
Dim objDAP As AccessObject
Dim f As Form
Dim r As Report
Dim c As Control
Dim ct As Long ' Pour ControlType.
Dim s As String
' For Each objDAP In CurrentProject.AllDataAccessPages
' For Each objDAP In CurrentProject.AllReports
For Each objDAP In CurrentProject.AllForms
' Debug.Print "The '" & objDAP.name & "' is located at: " &
objDAP.FullName
If (True) Then
i = i + 1
DoCmd.OpenForm objDAP.name, acDesign
Set f = Forms(objDAP.name)
Debug.Print Now() & ": " & objDAP.name
If ((f.RecordSource & "") <> "") Then
If (f.RecordSourceQualifier <> "dbo") Then
bASauvegarder = True
f.RecordSourceQualifier = "dbo"
' Debug.Print Now() & ": " & objDAP.name & ": Modifiée"
End If
End If
For Each c In f.Controls
' Debug.Print ctrl.Name
' If (TypeOf ctrl Is TextBox) Then
ct = c.ControlType
' 1) Liste des objets pouvant avoir un ControlSource.
' Note: acOptionButton peuvent également avoir un
RecordSource
' si leur parent n'est pas un acOptionGroup.
If (False And ct = acCheckBox Or _
ct = acComboBox Or _
ct = acListBox Or _
ct = acOptionGroup Or _
ct = acTextBox Or _
ct = acToggleButton Or _
ct = acBoundObjectFrame) Then
If (False) Then
bASauvegarder = True
End If
End If
' 1) Liste des objets pouvant avoir un RowSource.
If (ct = acComboBox Or ct = acListBox) Then
' Debug.Print Now() & ": " & c.RowSource
' Debug.Print Now() & ": " & c.RowSourceType
If (c.RowSourceType & "" = "Table/View/StoredProc")
Then
s = c.RowSource & ""
If (Left(s, 4) <> "dbo.") Then
c.RowSource = "dbo." & s
bASauvegarder = True
End If
End If
End If
Next
If (bASauvegarder = True) Then
bASauvegarder = False
DoCmd.Close acForm, objDAP.name, acSaveYes
Else
DoCmd.Close acForm, objDAP.name, acSaveNo
End If
End If
Next objDAP
End Function
' Reports.
Public Function Travail_Rapports_RecordSourceQualifier_dbo()
Dim bASauvegarder As Boolean
bASauvegarder = False
Dim i As Integer
i = 0
Dim objDAP As AccessObject
Dim f As Report
Dim c As Control
Dim ct As Long ' Pour ControlType.
Dim s As String
For Each objDAP In CurrentProject.AllReports
' Debug.Print "The '" & objDAP.name & "' is located at: " &
objDAP.FullName
If (True) Then
i = i + 1
DoCmd.OpenReport objDAP.name, acDesign
Set f = Reports(objDAP.name)
Debug.Print Now() & ": " & objDAP.name
If ((f.RecordSource & "") <> "") Then
If (f.RecordSourceQualifier <> "dbo") Then
bASauvegarder = True
f.RecordSourceQualifier = "dbo"
' Debug.Print Now() & ": " & objDAP.name & ": Modifiée"
End If
End If
For Each c In f.Controls
' Debug.Print ctrl.Name
ct = c.ControlType
' 1) Liste des objets pouvant avoir un ControlSource.
' Note: acOptionButton peuvent également avoir un
RecordSource
' si leur parent n'est pas un acOptionGroup.
If (False And ct = acCheckBox Or _
ct = acComboBox Or _
ct = acListBox Or _
ct = acOptionGroup Or _
ct = acTextBox Or _
ct = acToggleButton Or _
ct = acBoundObjectFrame) Then
If (False) Then
bASauvegarder = True
End If
End If
' 1) Liste des objets pouvant avoir un RowSource.
If (ct = acComboBox Or ct = acListBox) Then
' Debug.Print Now() & ": " & c.RowSource
' Debug.Print Now() & ": " & c.RowSourceType
If (c.RowSourceType & "" = "Table/View/StoredProc")
Then
s = c.RowSource & ""
If (Left(s, 4) <> "dbo.") Then
c.RowSource = "dbo." & s
bASauvegarder = True
End If
End If
End If
Next
If (bASauvegarder = True) Then
bASauvegarder = False
DoCmd.Close acReport, objDAP.name, acSaveYes
Else
DoCmd.Close acReport, objDAP.name, acSaveNo
End If
End If
Next objDAP
End Function