Always specify the user name of the owner of the object when you provide an object name for the
RecordSource property. For example, instead of typing
MyTable in the
RecordSource property, type
dbo.MyTable.
You can use the following subroutine to update all existing forms and reports.
Note This code assumes the owner is not already specified in the
RecordSource property and all objects have the same owner.
Sub AddOwnerPrefix()
Dim x As Object
Dim strOwner As String
strOwner = "dbo."
'Change the RecordSource property for all forms.
For Each x In CurrentProject.AllForms
DoCmd.OpenForm x.Name, acDesign, , , acFormPropertySettings, acHidden
Forms(x.Name).RecordSource = strOwner & Forms(x.Name).RecordSource
DoCmd.Close acForm, x.Name, acSaveYes
Next x
'Change the RecordSource property for all reports.
For Each x In CurrentProject.AllReports
DoCmd.OpenReport x.Name, acViewDesign
Reports(x.Name).RecordSource = strOwner & Reports(x.Name).RecordSource
DoCmd.Close acReport, x.Name, acSaveYes
Next x
MsgBox "Finished updating all forms and reports."
End Sub