query criteria from subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form (OffenderForm) with a subform (ComplaintForm). In the subform
is a command button to preview a report for a specific record whose key is on
the subform, the ComplaintKey. The criteria in the query is
[Forms]![OffenderForm]![Forms]![ComplaintForm]![ComplaintKey]

Part of the underlying VB code is
qdf.Parameters("Forms!OffenderForm!Forms!ComplaintForm!ComplaintKey") =
sfrm!ComplaintKey

I keep getting the "Enter Parameter Value" screen when trying to preview the
report. When debugging the VB code, I can see the correct value for the
Complaint Key is in "sfrm!ComplaintKey". I suspect that the format of the
Criteria statement in the query is incorrect for indicating a value on a
subform.

Can anyone please help? Thank you so much.
 
I have a form (OffenderForm) with a subform (ComplaintForm). In the subform
is a command button to preview a report for a specific record whose key is on
the subform, the ComplaintKey. The criteria in the query is
[Forms]![OffenderForm]![Forms]![ComplaintForm]![ComplaintKey]

Part of the underlying VB code is
qdf.Parameters("Forms!OffenderForm!Forms!ComplaintForm!ComplaintKey") =
sfrm!ComplaintKey

The syntax is incorrect. There should not be a second Forms! keyword.
If the Name property of the Subform Control on OffenderForm is
"ComplaintForm" - bearing in mind that both the Subform Control and
the form within that control have a Name property, and it's the former
that you need - try

[Forms]![OffenderForm]![ComplaintForm].Form![ComplaintKey]

Note that it's .Form! not !Forms!, and that it comes after the subform
control's name; you're referencing the Form property of the Subform
control, hence the . which delimites Properties, rather than the !
which delimits members of a collection.

John W. Vinson[MVP]
 
John, thank you very much.

John Vinson said:
I have a form (OffenderForm) with a subform (ComplaintForm). In the subform
is a command button to preview a report for a specific record whose key is on
the subform, the ComplaintKey. The criteria in the query is
[Forms]![OffenderForm]![Forms]![ComplaintForm]![ComplaintKey]

Part of the underlying VB code is
qdf.Parameters("Forms!OffenderForm!Forms!ComplaintForm!ComplaintKey") =
sfrm!ComplaintKey

The syntax is incorrect. There should not be a second Forms! keyword.
If the Name property of the Subform Control on OffenderForm is
"ComplaintForm" - bearing in mind that both the Subform Control and
the form within that control have a Name property, and it's the former
that you need - try

[Forms]![OffenderForm]![ComplaintForm].Form![ComplaintKey]

Note that it's .Form! not !Forms!, and that it comes after the subform
control's name; you're referencing the Form property of the Subform
control, hence the . which delimites Properties, rather than the !
which delimits members of a collection.

John W. Vinson[MVP]
 
Back
Top