Specifying query parameter value from form control?

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
 
D

Douglas J. Steele

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.
 
K

Ken Snell [MVP]

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
 
B

Bob Quintal

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]
 

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