Set Recordsource of Subreport

A

Alan Z. Scharf

Hi,

I want to set, in the main report, the recordsource for a subreport.

The recordsource of the subreport will change depending on the value of a
field in the main report.

What is the VBA syntax for this?

Would it be done in the OnOpen event of the main report?

Thanks.

Alan
 
D

Duane Hookom

I think this would only frustrate you. Changing the record source of a
subreport might be doable once. Can't you use the link master/child
properties rather than attempting to change the record source?
 
A

Alan Z. Scharf

Duane,

Thanks for your reply.

1. I probably didn't write my question well. I'm don't think can use
master/child links in this instance.

2. What I really need is to add a where clause to the SQL recordsource in
the subform, e.g. WHERE ShareClass = 'A', or use a Filter.
Whether this record restriction is applied depends on the report name
chosen from a listbox.

This is an ADP running off SQLServer.


3. I tried utting Filters and ServerFilters in both the Main form OnOpen
event, Main Form Detail section, and the subform OnOpen event.

me.ServerFilter = "[ShareClass] = 'A'"

I get message: "Setting you entered isn't valid for the property."


Is there any way to change the subreport recordsource at run time?

Thanks.

Alan
 
D

Duane Hookom

If there aren't too many different subreport record sources, you could use
multiple subreports and make the visible or invisible.

--
Duane Hookom
MS Access MVP

Alan Z. Scharf said:
Duane,

Thanks for your reply.

1. I probably didn't write my question well. I'm don't think can use
master/child links in this instance.

2. What I really need is to add a where clause to the SQL recordsource in
the subform, e.g. WHERE ShareClass = 'A', or use a Filter.
Whether this record restriction is applied depends on the report name
chosen from a listbox.

This is an ADP running off SQLServer.


3. I tried utting Filters and ServerFilters in both the Main form OnOpen
event, Main Form Detail section, and the subform OnOpen event.

me.ServerFilter = "[ShareClass] = 'A'"

I get message: "Setting you entered isn't valid for the property."


Is there any way to change the subreport recordsource at run time?

Thanks.

Alan
 
A

Alan Z. Scharf

Duane,

Thanks.

I'm trying to proliferate subreports.

I'll probably add an extra column to the tables involved, and then use those
in a master/child linking which I can control in code.

Alan


Duane Hookom said:
If there aren't too many different subreport record sources, you could use
multiple subreports and make the visible or invisible.

--
Duane Hookom
MS Access MVP

Alan Z. Scharf said:
Duane,

Thanks for your reply.

1. I probably didn't write my question well. I'm don't think can use
master/child links in this instance.

2. What I really need is to add a where clause to the SQL recordsource in
the subform, e.g. WHERE ShareClass = 'A', or use a Filter.
Whether this record restriction is applied depends on the report name
chosen from a listbox.

This is an ADP running off SQLServer.


3. I tried utting Filters and ServerFilters in both the Main form OnOpen
event, Main Form Detail section, and the subform OnOpen event.

me.ServerFilter = "[ShareClass] = 'A'"

I get message: "Setting you entered isn't valid for the property."


Is there any way to change the subreport recordsource at run time?

Thanks.

Alan


Duane Hookom said:
I think this would only frustrate you. Changing the record source of a
subreport might be doable once. Can't you use the link master/child
properties rather than attempting to change the record source?

--
Duane Hookom
MS Access MVP

Hi,

I want to set, in the main report, the recordsource for a subreport.

The recordsource of the subreport will change depending on the value of
a field in the main report.

What is the VBA syntax for this?

Would it be done in the OnOpen event of the main report?

Thanks.

Alan
 

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