473,382 Members | 1,204 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Weird Report Problem - Access 2003

I've got a report that's not sorting correctly. I build a SQL
statement and assign it to the recordsource in the Open event, sorting
the data the way the user chooses. The user can choose up to 3 sorts
using a form that opens before the report opens.

When the report previews, it ignores the users' sort request and always
sorts by the primary key even though ORDER BY is explicity set to
another field other than primary key.

If I copy the SQL into a query, then it sorts the way the user
requests.

If I comment out the Open event and apply the SQL statement directly in
the Record Source property, the report still sorts only by primary key
even though ORDER BY is explicity set.

The report consists of a report header/footer, page header/footer, and
detail. Grouping and Sorting is not set.

There is another report that is very similar to this one and it works
just fine.

Any ideas on why this is happening? I recreated the report - no
change. I even recreated the front-end thinking there was some
corruption - no change. I converted the mdb to 2000 - no change.

Nov 13 '05 #1
7 2403
My first thought would be that Access is misunderstanding the data type of
the column you are expecting it to sort by.

This could happen if:
a) You saved the report with some other RecordSource. Best to save with none
if you are planning to assign it in Report_Open.

b) The field you are sorting on is a calculated field.
To avoid this, typecast the calculation with CVDate().
More info in:
Calculated fields misinterpreted
at:
http://allenbrowne.com/ser-45.html

BTW, you did include:
Me.OrderByOn = True
in Report_Open *after* assigning the RecordSource?

--
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.

<ma**********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I've got a report that's not sorting correctly. I build a SQL
statement and assign it to the recordsource in the Open event, sorting
the data the way the user chooses. The user can choose up to 3 sorts
using a form that opens before the report opens.

When the report previews, it ignores the users' sort request and always
sorts by the primary key even though ORDER BY is explicity set to
another field other than primary key.

If I copy the SQL into a query, then it sorts the way the user
requests.

If I comment out the Open event and apply the SQL statement directly in
the Record Source property, the report still sorts only by primary key
even though ORDER BY is explicity set.

The report consists of a report header/footer, page header/footer, and
detail. Grouping and Sorting is not set.

There is another report that is very similar to this one and it works
just fine.

Any ideas on why this is happening? I recreated the report - no
change. I even recreated the front-end thinking there was some
corruption - no change. I converted the mdb to 2000 - no change.

Nov 13 '05 #2
Thanks for your reply.

No, Record Source is blank. No, none of the sortable fields are
calculated fields; they're all text. I didn't put in Me.OrderByOn =
True initially, but it made no difference when I did.

Here's what I did find though. The SQL statement combines 2 tables.
When I eliminated the 2nd table from the statement, then the report
sorted just fine. Then I added just one field from the 2nd table and
the sort is ignored again. So there's something in the SQL statement
that the report doesn't like but the query is OK with. I'm not sure
how many times in the past I've build SQL statements like this
combining multiple tables. This is the first time to my knowledge that
a report has ever done this.


Allen Browne wrote:
My first thought would be that Access is misunderstanding the data type of
the column you are expecting it to sort by.

This could happen if:
a) You saved the report with some other RecordSource. Best to save with none
if you are planning to assign it in Report_Open.

b) The field you are sorting on is a calculated field.
To avoid this, typecast the calculation with CVDate().
More info in:
Calculated fields misinterpreted
at:
http://allenbrowne.com/ser-45.html

BTW, you did include:
Me.OrderByOn = True
in Report_Open *after* assigning the RecordSource?

--
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.

<ma**********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I've got a report that's not sorting correctly. I build a SQL
statement and assign it to the recordsource in the Open event, sorting
the data the way the user chooses. The user can choose up to 3 sorts
using a form that opens before the report opens.

When the report previews, it ignores the users' sort request and always
sorts by the primary key even though ORDER BY is explicity set to
another field other than primary key.

If I copy the SQL into a query, then it sorts the way the user
requests.

If I comment out the Open event and apply the SQL statement directly in
the Record Source property, the report still sorts only by primary key
even though ORDER BY is explicity set.

The report consists of a report header/footer, page header/footer, and
detail. Grouping and Sorting is not set.

There is another report that is very similar to this one and it works
just fine.

Any ideas on why this is happening? I recreated the report - no
change. I even recreated the front-end thinking there was some
corruption - no change. I converted the mdb to 2000 - no change.


Nov 13 '05 #3
OK, found the problem. In the report footer, I sum 3 fields from the
2nd table. If I take those sum's out, then the report sorts fine. Why
would these make a difference?

Nov 13 '05 #4
The OrderByOn is essential, and you must place it after the assignment of
the RecordSource.

Adding a 2nd table should not make a difference.

You could try putting one field in the report's Sorting'n'Grouping dialog.
Then in Report_Open, reassign this to the appropriate field by setting the
ControlSource of the GroupLevel. Example in:
Sorting Records in a Report at runtime
at:
http://allenbrowne.com/ser-33.html

You're sure this is a Date/Time field in the table (not a text field that
looks like a date)?

--
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.

<ma**********@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Thanks for your reply.

No, Record Source is blank. No, none of the sortable fields are
calculated fields; they're all text. I didn't put in Me.OrderByOn =
True initially, but it made no difference when I did.

Here's what I did find though. The SQL statement combines 2 tables.
When I eliminated the 2nd table from the statement, then the report
sorted just fine. Then I added just one field from the 2nd table and
the sort is ignored again. So there's something in the SQL statement
that the report doesn't like but the query is OK with. I'm not sure
how many times in the past I've build SQL statements like this
combining multiple tables. This is the first time to my knowledge that
a report has ever done this.
Allen Browne wrote:
My first thought would be that Access is misunderstanding the data type
of
the column you are expecting it to sort by.

This could happen if:
a) You saved the report with some other RecordSource. Best to save with
none
if you are planning to assign it in Report_Open.

b) The field you are sorting on is a calculated field.
To avoid this, typecast the calculation with CVDate().
More info in:
Calculated fields misinterpreted
at:
http://allenbrowne.com/ser-45.html

BTW, you did include:
Me.OrderByOn = True
in Report_Open *after* assigning the RecordSource?

--
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.

<ma**********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
> I've got a report that's not sorting correctly. I build a SQL
> statement and assign it to the recordsource in the Open event, sorting
> the data the way the user chooses. The user can choose up to 3 sorts
> using a form that opens before the report opens.
>
> When the report previews, it ignores the users' sort request and always
> sorts by the primary key even though ORDER BY is explicity set to
> another field other than primary key.
>
> If I copy the SQL into a query, then it sorts the way the user
> requests.
>
> If I comment out the Open event and apply the SQL statement directly in
> the Record Source property, the report still sorts only by primary key
> even though ORDER BY is explicity set.
>
> The report consists of a report header/footer, page header/footer, and
> detail. Grouping and Sorting is not set.
>
> There is another report that is very similar to this one and it works
> just fine.
>
> Any ideas on why this is happening? I recreated the report - no
> change. I even recreated the front-end thinking there was some
> corruption - no change. I converted the mdb to 2000 - no change.

Nov 13 '05 #5
That suggests that the report's sorting is *undefined*, i.e. the OrderByOn
is not working. Try setting the Control Source of the GroupLevel so the
sorting is defined.

--
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.

<ma**********@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
OK, found the problem. In the report footer, I sum 3 fields from the
2nd table. If I take those sum's out, then the report sorts fine. Why
would these make a difference?

Nov 13 '05 #6
OK, think I got it by setting GroupLevel(n).ControlSource. At least
the report is sorting the way the user requests. Now, I had to "fudge"
some entries in Sorting and Grouping dialog to get the GroupLevel(n)
coding to work. Is that what you're supposed to do? Is that what you
meant by "you just need to make sure that you have set up the right
number of grouping levels in the report's grouping and sorting dialog"
in your tip?

Thanks for your help...

Nov 13 '05 #7
Yes, if you want to specify 2 levels of sorting, then you need to put 2
entries in the Sortin'nGrouping dialog at design time so you can manipulate
them at runtime.

--
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.

<ma**********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
OK, think I got it by setting GroupLevel(n).ControlSource. At least
the report is sorting the way the user requests. Now, I had to "fudge"
some entries in Sorting and Grouping dialog to get the GroupLevel(n)
coding to work. Is that what you're supposed to do? Is that what you
meant by "you just need to make sure that you have set up the right
number of grouping levels in the report's grouping and sorting dialog"
in your tip?

Thanks for your help...

Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kathy Houtami | last post by:
Hi there I've been encountered with weird compile error using Access 97. The error message is "Member or data member is not found" and it highlighted a line of code that has not be changed and...
2
by: pete moss | last post by:
I finally tried got around to converting an old access 2.0 databases to Access 2000 (these are backend front end databased with the back end tables still in 2.0) Most everything seems to work...
2
by: Del | last post by:
Thanks in advance for any help. I have a database that was created in Access 2000. Several users have been upgraded to Access 2003. Since upgrading to 2003 we have noticed that some of the...
5
by: bcanavan | last post by:
When I export xml(and xls) from Access 2003 the result is a complete report in a single page. I would like to get the entire report in a single page (one trip to the server) for printing and...
12
by: sparks | last post by:
My boss and I both have access 97 and access 2003 installed on our systems. Lately he has been having a lot of problems. Databases that won't close. The database looks like it closes but access...
2
by: Wayne | last post by:
I've been having a click around Access 2007 this afternoon and have discovered some things that range from annoying to alarming. My Access 2003 menu bars, which I, like many others, use...
1
by: PeaceManGroove | last post by:
It's a long story, but our application needs to run in Access 97. All of the computers in our organisation also run Access 2003. . . C++ code launches our Access reports via a VB 6.0 program. ...
4
by: Fran | last post by:
I recently tried to use code for "Use a multi-select list box to filter a report" from Allen Browne in my database. I was able to add the code and adapt it to my needs, however I am getting an...
10
Zwoker
by: Zwoker | last post by:
Greetings everyone, I have a report in MS Access 2003 that looks fine in print preview mode. When I click the print button the data on the printed output, in the first footer changes. Some of the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.