Specifying query parameter value from form control?

  • Thread starter Thread starter Chrisso
  • Start date Start date
C

Chrisso

Hi All

I have a query with a parameter [PN].

This works lovely when I run the query manually and enter a value for
[PN].

I have a main form with a PN value in a control - txtPN.

I now want to display a subform in this main form based on my query
with the [PN] parameter.

How do I configure the sub forms record source to take the [PN} from
the main form control?

I have tried on the subform:
Record Source: <my query>
Filter: [PN] = [Forms]![Main Form]![txtPN]

However when I view the main form I get the pop-up asking for [PN].

How do I make Access fill [PN] with the value in txtPN on my main
form?

Thanks in advance for any ideas,
Chrisso
 
Unfortunately, the subform is instantiated before the parent form is. That
means you can't use a query that pulls a field from the parent form as the
recordsource for your subform.
 
Or, leave the subform's RecordSource blank when it loads, then use the main
form's Load event to set the subform's RecordSource property to the desired
statement.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


Douglas J. Steele said:
Unfortunately, the subform is instantiated before the parent form is. That
means you can't use a query that pulls a field from the parent form as the
recordsource for your subform.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Chrisso said:
Hi All

I have a query with a parameter [PN].

This works lovely when I run the query manually and enter a value for
[PN].

I have a main form with a PN value in a control - txtPN.

I now want to display a subform in this main form based on my query
with the [PN] parameter.

How do I configure the sub forms record source to take the [PN} from
the main form control?

I have tried on the subform:
Record Source: <my query>
Filter: [PN] = [Forms]![Main Form]![txtPN]

However when I view the main form I get the pop-up asking for [PN].

How do I make Access fill [PN] with the value in txtPN on my main
form?

Thanks in advance for any ideas,
Chrisso
 
m:
Hi All

I have a query with a parameter [PN].

This works lovely when I run the query manually and enter a value
for [PN].

I have a main form with a PN value in a control - txtPN.

I now want to display a subform in this main form based on my
query with the [PN] parameter.

How do I configure the sub forms record source to take the [PN}
from the main form control?

I have tried on the subform:
Record Source: <my query>
Filter: [PN] = [Forms]![Main Form]![txtPN]

However when I view the main form I get the pop-up asking for
[PN].

How do I make Access fill [PN] with the value in txtPN on my main
form?

Thanks in advance for any ideas,
Chrisso

1) redesign the query to remove the parameter.
2) Set the Link Child fields property and link parent fields
property of the subform control to [PN] and [PN]
 
Back
Top