Query for report?

  • Thread starter Thread starter MJJ
  • Start date Start date
M

MJJ

I have a report I am using w/ a query based on the "id"
field. But I want to be able to sort on different
fields. So I create a form with radio buttons which
allows me to choose a sort I want; id, last name...etc.
What I would like to do is to put a 'variable' in the
OrderBy in the SQL stmnt and just change it in the VBA
code? Is this possible? Or should I prepare the
different queries I need and go from there? Thanks
 
MJJ,

Generally, the sort order of your report should be controlled through
the Sorting and Grouping dialog via the report design.

If you put your radio buttons within an option group, you will be able
to set up your sort based on an expression something like this...
=Choose([Forms]![NameOfForm]![NameOfOptionGroup],[id],[last
name],[something else])

Of course, this requires that the form is open at the time that the
report is printed.
 
-----Original Message-----
MJJ,

Generally, the sort order of your report should be controlled through
the Sorting and Grouping dialog via the report design.

If you put your radio buttons within an option group, you will be able
to set up your sort based on an expression something like this...
=Choose([Forms]![NameOfForm]![NameOfOptionGroup],[id],
[last
name],[something else])

Of course, this requires that the form is open at the time that the
report is printed.

--
Steve Schapel, Microsoft Access MVP

I have a report I am using w/ a query based on the "id"
field. But I want to be able to sort on different
fields. So I create a form with radio buttons which
allows me to choose a sort I want; id, last name...etc.
What I would like to do is to put a 'variable' in the
OrderBy in the SQL stmnt and just change it in the VBA
code? Is this possible? Or should I prepare the
different queries I need and go from there? Thanks
.
Hey;
Thanks for the reply! I understand how to choose the
option, I'm not sure how to change the sort order in the
report itself within VBA code?
 
MJJ,

Yes, and I am suggesting you do not try to manipulate the sort order
within VBA code, I am suggesting instead that you sort using a Choose()
function within the report's Sorting and Grouping. Don't you like my idea?
 
-----Original Message-----
MJJ,

Yes, and I am suggesting you do not try to manipulate the sort order
within VBA code, I am suggesting instead that you sort using a Choose()
function within the report's Sorting and Grouping. Don't you like my idea?

--
Steve Schapel, Microsoft Access MVP

.
Are you saying to put the Choose function in the Sorting
& Grouping? If yes, that now makes sense! I will try
that.
The Choose func is not in the Help but I will experiment.
Thanks!
 
Finding the Choose() function in Help (Access 2002 module window) is really
odd. I typed
Choose Function
in the Clippy "What would you like to do?" box, it doesn't find the
function. However if you search for
Functions
and then choose "See More..." it shows
Choose Function
Go figure!
 
-----Original Message-----
Finding the Choose() function in Help (Access 2002 module window) is really
odd. I typed
Choose Function
in the Clippy "What would you like to do?" box, it doesn't find the
function. However if you search for
Functions
and then choose "See More..." it shows
Choose Function
Go figure!

--
Duane Hookom
MS Access MVP
--




.
Anyway, your sug worked great. Thanks for the help!
 
Back
Top