I wanted to use Crosstab query to generate my report.
Since the fiedl names depend on the row heading which is vary, I need link
fields at run time.
Please let me know if I am wrong,
If I need link the field at run time, can you please give me any example code?
Your help is great appreciated,
One way to do this is to alias the field names so they don't change.
Duane Hookom has an example:
dynamic monthly crosstab reports
at:
http://www.access.hookom.net/DynamicMthlyCrosstabRpt.htm
If you want to do it programmatically, you will need to be familiar with VBA
code. Set up the report with the maximum number of text boxes you could
need. Name them txt0, txt1, etc, and leave them unbound. In the Open event
of the report, OpenRecordset on a Totals query that will let you determine
the field names you need, and assign them to the ControlSource of the
unbound text boxes. At the same time, generate the list to include in the
PIVOT clause, and assign the entire SQL statement to the RecordSource of the
report.

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
>I wanted to use Crosstab query to generate my report.
> Since the fiedl names depend on the row heading which is vary, I need link
[quoted text clipped - 4 lines]
> If I need link the field at run time, can you please give me any example
> code?
Souris - 25 Mar 2008 13:56 GMT
Thanks millions,
> One way to do this is to alias the field names so they don't change.
> Duane Hookom has an example:
[quoted text clipped - 19 lines]
> > If I need link the field at run time, can you please give me any example
> > code?
Souris - 27 Mar 2008 12:05 GMT
Can you please let me know if I am on the right track using following code?
dim rs as DAO.recordset
set rs = Report.RecordSource.openRecordset
If rs.Field("MyField")<> null then
txtMyField.ControlSource = "MyField"
else
txtMyField.ControlSource = null
end if
Thanks millions,
> One way to do this is to alias the field names so they don't change.
> Duane Hookom has an example:
[quoted text clipped - 19 lines]
> > If I need link the field at run time, can you please give me any example
> > code?
Allen Browne - 27 Mar 2008 14:48 GMT
FWIW, I've uploaded an example here:
http://allenbrowne.com/temp/CrosstabExample.txt
The report has:
- 20 unbound text boxes (named txt0 to txt19) in the Detail section;
- 20 labels (named lbl0 to lbl19) in the Page Header section;
- 20 unbount text boxes (txtFoot0 to txtFoot10) in the Report Footer.

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
> Can you please let me know if I am on the right track using following
> code?
[quoted text clipped - 40 lines]
>> > example
>> > code?
Souris - 28 Mar 2008 20:41 GMT
Thanks millions
> FWIW, I've uploaded an example here:
> http://allenbrowne.com/temp/CrosstabExample.txt
[quoted text clipped - 48 lines]
> >> > example
> >> > code?