Column shown dynamically in datasheet form or List box as per the availability of data in crosstab query (1 Viewer)

ahmad_rmh

Member
Local time
Today, 19:39
Joined
Jun 26, 2022
Messages
243
I want to make datasheet form or List box but the columns should have to be shown in datasheet form or List box dynamically as per the availability of data in cross tab query.


suggest please.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 17:39
Joined
Feb 19, 2013
Messages
16,614
Easiest way is to have a subform control on a form and set its source object to

query.mycrosstabqueryname
 

ahmad_rmh

Member
Local time
Today, 19:39
Joined
Jun 26, 2022
Messages
243
Easiest way is to have a subform control on a form and set its source object to

query.mycrosstabqueryname

Doing in the same way but as the new data columns added in cross tab query the sub form just showing the old columns and not adding the new columns.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:39
Joined
May 7, 2009
Messages
19,245
can you set the SourceObject of the subform to the query.yourQueryName?

//already in post#2
 

CJ_London

Super Moderator
Staff member
Local time
Today, 17:39
Joined
Feb 19, 2013
Messages
16,614
the sub form just showing the old columns and not adding the new columns
In that case you are not doing what was suggested
 

ahmad_rmh

Member
Local time
Today, 19:39
Joined
Jun 26, 2022
Messages
243
Easiest way is to have a subform control on a form and set its source object to

query.mycrosstabqueryname

thanks CJ, & Arnel, Done & Solved,

Now I want to implement the same way in report.

How to implement?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:39
Joined
May 7, 2009
Messages
19,245
How to implement?
the same way as in Form, you add a SubForm and on the Open Event of the Report, set the SourceObject of the SubForm.
 

ahmad_rmh

Member
Local time
Today, 19:39
Joined
Jun 26, 2022
Messages
243
the same way as in Form, you add a SubForm and on the Open Event of the Report, set the SourceObject of the SubForm.

It just show datasheet form in report view, I want to show as a report view.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:39
Joined
Feb 19, 2002
Messages
43,275
I have a sample database that includes a custom form made from a cross-tab. You do need to create a report with a fixed number of columns. Access report width are restricted so 20 columns is probably all you can get on a single page width at landscape. So, keep that in mind as you are designing this. I think the max width is ~ 22" so it is two landscape pages max.

The process starts with a select query that gathers the unique values that will be columns and adds them to a table. So, for example, if your data set is expenses and those will be the column headings. The table might look like this:
1, Oil
2, Water
3, Lawn
4, Electric
5, Snow Removal

The columns of the report are bound to fields named 1,2,3,4,5 and the code in the report builds the column header fields from this table so the column names end up as Oil, Water, Lawn, Electric, Snow Removal as you would want.

 

Users who are viewing this thread

Top Bottom