Report Sort Order

M

Martin

Hello,

I have an option button on a form that the default value is -1. This means
the report will sort by that field. What I want to happen is the user can
click in the option button to change the value to 0 and so not sort on the
field.

However I get an error message saying the control source is incorrect.

i know you have to have the correct number of groupings for the correct
number of options buttons on the form but is there anyway for me to say
programatically is the option button is equal to 0 then no sorting or
grouping exists for that field?

Here is the code:

If Forms![FORM NAME]!FIELDNAME = -1 Then Me.GroupLevel(0).ControlSource =
"FIELDNAME" Else Me.GroupLevel(0).ControlSource = ""

Many thanks for your help.

Martin
 
M

Marshall Barton

Martin said:
I have an option button on a form that the default value is -1. This means
the report will sort by that field. What I want to happen is the user can
click in the option button to change the value to 0 and so not sort on the
field.

However I get an error message saying the control source is incorrect.

i know you have to have the correct number of groupings for the correct
number of options buttons on the form but is there anyway for me to say
programatically is the option button is equal to 0 then no sorting or
grouping exists for that field?

Here is the code:

If Forms![FORM NAME]!FIELDNAME = -1 Then Me.GroupLevel(0).ControlSource =
"FIELDNAME" Else Me.GroupLevel(0).ControlSource = ""


Use any constant **expression**. E.g.

.... Else Me.GroupLevel(0).ControlSource = "=1"
 

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