473,397 Members | 2,077 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,397 software developers and data experts.

Formatting Charts in a Form

Hello,

I have a form that creates a chart for me that displays the number of occurances (y-axis) by month (x-axis). The data is retrieved from a make-table. When the chart is created it plots the months on the x-axis in alphabetical order (Apr-Sep). How do I change it so it orders the months correctly (Jan-Dec).

(In the make-table, the data is listed properly from Jan to Dec)

Thanks!
Sep 30 '08 #1
13 2801
NeoPa
32,556 Expert Mod 16PB
Convert your month strings into dates (all for the same year - it doesn't matter which one) then order by that value rather than the strings.

Use CDate() to convert from a string to a Date.
Sep 30 '08 #2
Convert your month strings into dates (all for the same year - it doesn't matter which one) then order by that value rather than the strings.

Use CDate() to convert from a string to a Date.

I think that is what I am doing in a round about way. I have a field for Month([DATE]) which returns values 1-12. That field is ordered ascending and is not shown. Then I have a field consisting of successive "IIF" statements to convert the Month([DATE]) into words.

Ex. IIF(Month([DATE])=1, "Jan", IIF(Month([DATE])=2, "Feb",.......IIF(Month([DATE])=12, "Dec"

When I run the make-table it orders by the unshown numeric field and displays the text field. The table is then ordered correctly, but when I send it to the graph form it alphabetizes the text months.
Sep 30 '08 #3
NeoPa
32,556 Expert Mod 16PB
When you "send it to the graph" ensure that it has the already calculated month number to work from.

When converting from a numeric month (Assume it is in variable intMonth) simply use :
Expand|Select|Wrap|Line Numbers
  1. Format(CDate(intMonth & "/21/2000"), "mmm")
NB. Using a day of 21 means this should work whether the standard is d/m/y or m/d/y. Also, the CDate() part is not strictly necessary, but it makes the code clearer.
Sep 30 '08 #4
Expand|Select|Wrap|Line Numbers
  1. Format(CDate(intMonth & "/21/2000"), "mmm")
This is definitley a better way to convert month (1-12) into (Jan-Dec), but it still does the same thing as before. When the make table is generated, it successfully lists the months Jan - Dec. But when the chart is created from the table in a form, it still aranges the months on the x-axis alphabetically (apr-sep)
Sep 30 '08 #5
NeoPa
32,556 Expert Mod 16PB
When you "send it to the graph" ensure that it has the already calculated month number to work from.
My first sentence is the one to focus on for that problem.

I know nothing about charts per se, yet it's obvious to me, as someone who deals with other database entities, what needs doing in general terms.

I can't give more detailed instruction at this stage, although I would expect I could if you had posted the code you're currently using. Then it might be obvious what small thing needs to change.

Generally posting questions is about helping us to help you. If you put in the bare minimum, then you're less likely to get what you need.
Sep 30 '08 #6
Expand|Select|Wrap|Line Numbers
  1. SELECT Format(CDate(Month([Date_NextOH]) & '/21/2000'),'mmm') AS Monthtext,
  2.        Count(Month([Date_NextOH])) AS OHMonth,
  3.        Year([Date_NextOH]) AS Year
  4.  
  5. INTO tbl_OHbymonth
  6.  
  7. FROM tbl_totatOHDates
  8.  
  9. GROUP BY Format(CDate(Month([Date_NextOH]) & '/21/2000'),'mmm'),
  10.          Year([Date_NextOH]),
  11.          Month([Date_NextOH])
  12.  
  13. HAVING (((Year([Date_NextOH]))=[Forms]![frm_Main]![tb_graphyear]))
  14.  
  15. ORDER BY Month([Date_NextOH])
That is the SQL. The query is generating the make-table correctly, the months are listed Jan-Dec. Then a form runs this make-table and graphs it, with months along the x-axis. However, it lists the months alphabetically instead of retaining the order they are listed in the make-table.

I'm honestly trying to be as specific as possible, but that's really all there is to it. If there is anything that could be clearer, please let me know.
Sep 30 '08 #7
NeoPa
32,556 Expert Mod 16PB
I'm honestly trying to be as specific as possible, but that's really all there is to it. If there is anything that could be clearer, please let me know.
OK. I can work with that.

You keep referring to a Make-Table query, yet the SQL posted is a SELECT query. Is the table [totatOHDates] the one created by the MT query?

Is the SQL posted what your graph is built on?
Sep 30 '08 #8
You keep referring to a Make-Table query, yet the SQL posted is a SELECT query.
I'm not sure why it says SELECT in the SQL, it is definitely a successfully functioning make-table query, qry_graphbymonth generates tbl_graphbymonth.

Is the table [totatOHDates] the one created by the MT query?
No, totatOHDates is a seperate table that this query pulls raw dates from before counting the number of occurences in each month.

Is the SQL posted what your graph is built on?
No, that SQL is just the a query that counts how many date data points fall within each month of the year. The year is specified from the form by the criteria "[Form]![frm_main]![tb_graphyear]"

Then a form uses a command button to run the above query (generateing the make-table) and run a seperate form to graph the make-table. The code for that is as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub tb_graphyear_Exit(Cancel As Integer)
  2. DoCmd.SetWarnings False
  3. DoCmd.OpenQuery "qry_OHbymonth"
  4. DoCmd.OpenForm "frm_graphbymonth"
  5. DoCmd.SetWarnings True
  6. End Sub
  7.  
Finally, the code for "frm_graphybymonth" is just a graph that was created with the chart wizard to plot the months on the x-axis, and the number of data points occuring in that month on the y-axis. This form also operates correctly except it orders the months alphabetically.
Sep 30 '08 #9
NeoPa
32,556 Expert Mod 16PB
Now I have clarified the SQL it is clear that it actually IS the Make-Table query.

Let me start simply by posting some equivalent SQL that should be a little neater, but have the same effect :
Expand|Select|Wrap|Line Numbers
  1. SELECT Format([Date_NextOH],'mmm') AS MonthText,
  2.        Count(Month([Date_NextOH])) AS OHMonth,
  3.        Year([Date_NextOH]) AS Year
  4.  
  5. INTO tbl_OHbymonth
  6.  
  7. FROM tbl_totatOHDates
  8.  
  9. WHERE (Year([Date_NextOH])=[Forms]![frm_Main]![tb_graphyear])
  10.  
  11. GROUP BY Format([Date_NextOH],'mmm'),
  12.          Year([Date_NextOH])
  13.  
  14. ORDER BY Month([Date_NextOH])
Grouping by the month value again was redundant.
The HAVING clause should really have been a WHERE clause (You probably have Access to blame for that - It routinely uses HAVING for WHERE in GROUP BY queries).
Sep 30 '08 #10
Yeah, this was created in design view, then I just copied the SQL.

I'm concerned the problem lies in some setting the chart wizard uses that tells it to alphabetize any text field it graphs, the order seems to stay correct until that point.
Sep 30 '08 #11
NeoPa
32,556 Expert Mod 16PB
Finally, the code for "frm_graphybymonth" is just a graph that was created with the chart wizard to plot the months on the x-axis, and the number of data points occuring in that month on the y-axis. This form also operates correctly except it orders the months alphabetically.
I need to see what you use as the Record Source of this form.

In here will need to be the correct Ordering By. I'm a little out of my depth with the form itself, but if I can see the SQL of that query then I'm confident I can provide one similar except that it sorts in the way you want it.
Sep 30 '08 #12
Figured it out...thanks to your guidance.

The make-table was passing the numerical month that was sorted ascendingly to the graph, but it was not selected in the row source of the graph, only the text month. Got it fixed.

Thanks for your help!
Oct 1 '08 #13
NeoPa
32,556 Expert Mod 16PB
My pleasure, but just to clarify in case someone else views this :

The order of the make-table query is entirely irrelevant. The order it goes into the form (controlled either explicitly by a setting in the form or, if that's absent, in the order of the record source of the form) is what needs to be maniplulated to effect this change.
Oct 1 '08 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have...
2
by: woodglass | last post by:
I am writing a VB6/SQL Server database app. I know I can't add charts to data reports. What is the best means of creating printable reports containing charts - should I simply create a form...
3
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
0
by: deejayquai | last post by:
Hi(again) 2nd try with this (sorry!) My question is this- I would like to display different charts on a form that either randomly changes everytime the form is opened or depending on the...
8
by: Don Wash | last post by:
Hi There! I'm using CrystalReportsViewer control in my ASP.NET page to display the report. How do I increase the image quality of charts produced by Crystal Reports ..NET report file? Many...
4
by: rdemyan via AccessMonster.com | last post by:
Lately I've been noticing that charts that are created in my application don't always appear. When they don't appear, it is a consistent nonappearance. But then if I close the app and reopen it,...
5
by: Wayne | last post by:
Several of my Access 2003 databases are exhibiting the same problem under Windows Vista. Charts in forms are not showing any data. Reports are not affected. Charts in reports display as they...
3
by: David | last post by:
Hi Has anyone experienced any problems with embedded charts on forms when running windows vista? I'm running Access 2000 (old I know) and have noticed that embedded charts don't appear, unless...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.