RecordSourceQualifier

V

Vayse

Hi
I'm using an ADP that was developed in Access 2000, in Office XP. ADPs in
Office XP seem to require a RecordSourceQualifier. Its set on some of my
reports, but not on others.
For example, if I had the record source as 'Clients' instead of
'dbo.Clients' then the report won't work. If I set the RecordSourceQualifier
to dbo then the problem is fixed.

Anyone know the code for stepping through all reports and setting the
RecordSourceQualifier property?

Thanks
Vayse
 
S

Sylvain Lafontaine

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
 
V

Vayse

Thanks Sylvain, some very useful code there.



Sylvain Lafontaine said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top