option fields output

I

inungh

I have a quesry to return 10 fields. I would like to let user use
radio button to select which fields users want to see in the report.

Are there any easy way to handle this to have optional fields output
from a query?

Your help is great appreciated,
 
K

KARL DEWEY

Use an option group on a form to make selection. Use that option group data
as criteria in a union query to feed your report.

SELECT Field_X, Field1 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 1
UNION ALL SELECT Field1, Field2 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 2
UNION ALL SELECT Field1, Field3 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 3;
 
I

inungh

Use an option group on a form to make selection.  Use that option groupdata
as criteria in a union query to feed your report.

SELECT Field_X, Field1 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 1
UNION ALL SELECT Field1, Field2 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 2
UNION ALL SELECT Field1, Field3 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 3;

--
Build a little, test a little.



inungh said:
I have a quesry to return 10 fields. I would like to let user use
radio button to select which fields users want to see in the report.
Are there any easy way to handle this to have optional fields output
from a query?
Your help is great appreciated,- Hide quoted text -

- Show quoted text -

Thanks for the message,
Should the third union all for 3 fields, field1, field2, field3 and
the 4th should be 4 fields?
Thanks again,
 
I

inungh

Use an option group on a form to make selection.  Use that option groupdata
as criteria in a union query to feed your report.

SELECT Field_X, Field1 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 1
UNION ALL SELECT Field1, Field2 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 2
UNION ALL SELECT Field1, Field3 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 3;

--
Build a little, test a little.



inungh said:
I have a quesry to return 10 fields. I would like to let user use
radio button to select which fields users want to see in the report.
Are there any easy way to handle this to have optional fields output
from a query?
Your help is great appreciated,- Hide quoted text -

- Show quoted text -

it seems this is output 2 fields, I would like to let user output from
1 to 10 fields when user wants.

Thanks again,
 
K

KARL DEWEY

Error in previous post ---
SELECT Field_X, Field1 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 1
UNION ALL SELECT Field_X, Field2 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 2
UNION ALL SELECT Field_X, Field3 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 3;


You can only select one using an option group. This outputs a field plus
one choice, not choose multiple fields. Or you can output multiple fields
all the time plus one choice of many.

You could do it differently by using check boxes to make selections. Then
use the union query. The report would look something like this --

Field1 FieldName SelectedFieldData
FieldName SelectedFieldData
FieldName SelectedFieldData
FieldName SelectedFieldData

Field1 FieldName SelectedFieldData
FieldName SelectedFieldData
FieldName SelectedFieldData
FieldName SelectedFieldData

SELECT Field_X, "Field1Name" As Field_Y, Field1 AS [SelectedFieldData]
FROM YourTable
WHERE [Forms]![YourForm]![cbo1] = -1
UNION ALL SELECT Field_X, "Field1Name" As Field_Y, Field2 AS
[SelectedFieldData]
FROM YourTable
WHERE [Forms]![YourForm]![cbo2] = -1
UNION ALL SELECT Field_X, "Field1Name" As Field_Y, Field3 AS
[SelectedFieldData]
FROM YourTable
WHERE [Forms]![YourForm]![cbo3] = -1;

--
Build a little, test a little.


inungh said:
Use an option group on a form to make selection. Use that option group data
as criteria in a union query to feed your report.

SELECT Field_X, Field1 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 1
UNION ALL SELECT Field1, Field2 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 2
UNION ALL SELECT Field1, Field3 AS [Something]
FROM YourTable
WHERE [Forms]![YourForm]![Frame0] = 3;

--
Build a little, test a little.



inungh said:
I have a quesry to return 10 fields. I would like to let user use
radio button to select which fields users want to see in the report.
Are there any easy way to handle this to have optional fields output
from a query?
Your help is great appreciated,- Hide quoted text -

- Show quoted text -

it seems this is output 2 fields, I would like to let user output from
1 to 10 fields when user wants.

Thanks again,
 

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