Cannot determine "Rogue" parameter

G

Guest

I have a report with many subreports. I have Parent / Child Links from the
main report to each subreport. I have checked all the links and they look
correct, but I still recieve a message to enter a parameter, when I try to
run the report. When I run each subreport independently Access asks me for
the correct parameter(that is passed in from the main form). Is there a way
to determine which query is causing this problem?
 
A

Allen Browne

When you open the report, write down *exactly* the name of the parameter it
asks for, including any spaces.

You can then search the report and subreports for that name. As well as the
Control Source of the controls, you need to look in Sorting And Grouping
dialog, as well as in the report's Filter and OrderBy properties.

If you can't find ti you can modify the code example below so it refers to
Reports instead of forms, and then use it to locate the culprit
programmatically.

Function FindInForms(ByVal strword As String)
Dim accObj As AccessObject
Dim ctl As Control
Dim strDoc As String
Dim strCtl As String

strword = "*" & strword & "*"

For Each accObj In CurrentProject.AllForms
strDoc = accObj.Name
DoCmd.OpenForm strDoc, acDesign, WindowMode:=acHidden
With Forms(strDoc)
For Each ctl In .Controls
strCtl = ctl.Name
If strCtl Like strword Then
Debug.Print strDoc & "." & ctl.Name
Else
If HasProperty(ctl, "ControlSource") Then
If ctl.ControlSource Like strword Then
Debug.Print strDoc & "." & ctl.Name
End If
End If
End If
Next
End With

DoCmd.Close acForm, strDoc
Next

Set accObj = Nothing
End Function
Public Function HasProperty(obj As Object, strPropName As String) As Boolean
'Purpose: Return true if the object has the property.
Dim vardummy As Variant

On Error Resume Next
vardummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
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