I need to create a sql statement in MS Access from only the last 12 columns a table that has has dates (the last days of the month) as the names of the columns. In actuality, each column is part of table that is sent to my office monthly. I only use one particular column and discard the rest. The columns in the table then looks like this: - 2_29_2008 || 1_31_2007 || 12_31_2007 11_30_2007 10_31_2007 ...etc.....1_31_2007
I need to be able to select any month dynamically and select the last 12 months only.
Another idea is to use the whole tables but I the requirement is that the last 12 months must be gathered. What it basically shows is the number of errors made by a person, so the previous months represent previous performance.
I am very desperate, any help is greatly appreciated!
Richard
101 6747 NeoPa 32,556
Expert Mod 16PB
Are you creating (expecting to create) the SQL statement in code?
This can be done using code but might be fiddly. A clearer indication of exactly what you're dealing with is likely to be crucial.
Are you creating (expecting to create) the SQL statement in code?
This can be done using code but might be fiddly. A clearer indication of exactly what you're dealing with is likely to be crucial.
Yes the SQL statement is to be created in code. Basically what this is about is measuring the performance of employess in terms of how many errors they made this month and compare the current figure with the ones made before. For example, for employee A the number of errors for the Month of March 2008 is 324, for february 2008 is 420, for January 2008 is 200, etc....going all the back to the month of March 2007 and see how the errors have increased or decreased over time. The users of this application want to be able to do this by picking from any given month and look back up to a year in monthly increments
and measure performance. I thought of creating arrays for each month but something goes wrong......
NeoPa 32,556
Expert Mod 16PB
How many columns are there then in the data?
Is the number fixed?
How are they positioned relative to the current month (Month(Date()))?
Where is the code to run from?
What is the SQL that you want as a result of a run done now?
With these answers we can look at how to produce the SQL relative to the data required.
How many columns are there then in the data?
Is the number fixed?
How are they positioned relative to the current month (Month(Date()))?
Where is the code to run from?
What is the SQL that you want as a result of a run done now?
With these answers we can look at how to produce the SQL relative to the data required.
Great! there are 12 columns in the table. They are positioned stating from the very first month and year. For example, If the current month is March 2008, then next month will be March 2007, then April 2007, May 2007, June 2008, etc....finishing in March 2008.
The code can run from a form or by way of a query. This is what I have written so far ...based on fake data : - SELECT UserName,
-
Count([January 2007]) AS [Jan 2007],
-
Count([February 2007]) AS [Febuary 2007],
-
Count([March 2007]) AS [Mrch 2007],
-
Count([April 2007 ]) AS [Aprl 2007],
-
Count([May 2007 ]) AS [My 2007],
-
Count([June 2007 ]) AS [Jun 2007],
-
Count([July 2007]) AS [Jul 2007],
-
Count([August 2007]) AS [Aug 2007],
-
Count([September 2007 ]) AS [Sept 2007],
-
Count([November 2007 ]) AS [Nov 2007],
-
Count([December 2007 ]) AS [Dec 2007],
-
Count([January 2008]) AS [Jan 2008],
-
Count([February 2008]) AS [Feb 2008]
-
FROM xtbMEQA_MONTH
-
GROUP BY UserName;
I created a crosstab query then added date functions from the original date column that received the date of the error. This was one column that had many rows of dates. The cross tab column took care of the rest -- this is all I could think of.
NeoPa 32,556
Expert Mod 16PB
Sorry, had a busy Admin evening so may need to get to this tomorrow.
If you don't see a further reply tomorrow please * Bump * the thread as a reminder.
I'm not sure If I did this the way to BUMP a message but here it goes :
I need to create a sql statement in MS Access from only the last 12 columns a table that has has dates (the last days of the month) as the names of the columns. In actuality, each column is part of table that is sent to my office monthly. I only use one particular column and discard the rest. The columns in the table then looks like this:
Code: ( text )
2_29_2008 || 1_31_2007 || 12_31_2007 11_30_2007 10_31_2007 ...etc.....1_31_2007
I need to be able to select any month dynamically and select the last 12 months only.
Another idea is to use the whole tables but I the requirement is that the last 12 months must be gathered. What it basically shows is the number of errors made by a person, so the previous months represent previous performance.
I am very desperate, any help is greatly appreciated!
Richard
This what I wrote at the beginning tof the thread
Someone suggested using getrows with ubound or maybe the fields.count preoperty........any thoughts?
NeoPa 32,556
Expert Mod 16PB
Bumping is simply adding a new post (contents irrelevant) so that the thread moves up to the top (most recently added to) in the list of threads.
Don't worry, I will catch up with this today (or tomorrow latest) and answer the original question first. I always try to work in order. Extra questions can wait until I've covered the outstanding ones at least.
I haven't forgotten you ;)
Thank you very much. I really appreciate it
Richard
NeoPa 32,556
Expert Mod 16PB
Right, I went back to post #5 and I had to reformat your SQL to be able to read it. The effect is unchanged btw.
Unfortunately, I suspect there's something not quite right with processing the results of a crosstab the way you have proposed. It seems to me that the crosstab would produce the sort of figures you are after without needing to GROUP by the [UserName].
Can you post in some sample data for the crosstab query so I can get a feel for the sort of data we're dealing with? Are there more than one lines for each [UserName]?
BTW, what is going on with the names of the fields in there? There are various with extra spaces, both within and at the end of field names, as well as some very unusual abbreviations that are supposed to represent months. This may not seem important now, but it will soon when we try to get the code to produce your SQL for you.
Right, I went back to post #5 and I had to reformat your SQL to be able to read it. The effect is unchanged btw.
Unfortunately, I suspect there's something not quite right with processing the results of a crosstab the way you have proposed. It seems to me that the crosstab would produce the sort of figures you are after without needing to GROUP by the [UserName].
Can you post in some sample data for the crosstab query so I can get a feel for the sort of data we're dealing with? Are there more than one lines for each [UserName]?
BTW, what is going on with the names of the fields in there? There are various with extra spaces, both within and at the end of field names, as well as some very unusual abbreviations that are supposed to represent months. This may not seem important now, but it will soon when we try to get the code to produce your SQL for you.
Here's some sample data from the query: - UserName 1/31/2007 2/28/2007 3/31/2007 4/30/2007
-
dang_ht 3175 2647 3440 3966
-
desai_ra 1477 916 1365 2243
-
diep_kk 1828 2911 3490 2482
-
diep_tk 1952 1617 1105 1808
-
djauhar_aj 1828 1913 1215 165
-
fazeli_np 1727 3276 2003 1785
-
guirgui_es 2065 2407 2561 2402
-
hoang_cq 1082 506 1255 1146
-
hoang_hn 1324 1836 1863
-
huynh_cn 1460 863 497 444
-
juson_kn 1495 2961 1815
-
lam_at 1483 1439 2216 2741
-
lam_mu 1732 1628 2207 1965
-
lam_td 2082 4291 1668
-
lau_sc 2350 2572 1473 4022
-
le_am 1627 1393 1789 2173
-
lee_ee 1673 2643 2456 2347
-
lee_jy 1266 3509 1600
-
lee_ke 1919 2421 1511 1179
-
lui_ey 2214 360 1506 1578
-
luong_dn 1509 1068 1005 1242
-
mackey_yr 2056 1392 1432 1073
-
mai_jm 87 1791 1134
-
martino_gc 2668 1791 1104 1191
-
nemeh_ga 1
-
nghiem_tn 1684 2895 3335 3030
-
nguyen_ad 965 2416 1084
-
nguyen_al 1308 1438 1861 2360
-
nguyen_ct 876 1883 1456
-
nguyen_ea 1132 2587 1248
-
nguyen_ja 1
-
-
I have another query that needs to be handled in the same manner (rolling dynamically as described below. This other one is a type of errors data that each user has generated. The data I just posted is the more broad type of errors that the users have generated ( I hope I'm not confusing you too much)the other data loos like this: -
-
Initials MEQA Month DateReceived
-
EYL 1 January 2008 1/15/2008
-
EJW 1 January 2008 1/15/2008
-
EAN 4 June 2007 6/13/2007
-
AMN 1 June 2008 6/12/2008
-
EAN 1 June 2008 6/12/2008
-
AMN 3 March 2007 3/4/2007
-
AMN 1 March 2007 3/6/2007
-
EYL 1 March 2008 3/10/2008
-
EJW 1 March 2008 3/7/2008
It is from this point that I created the crosstab queries.
I can also show you the crosstab queries too.
Thanks,
Richard
Right, I went back to post #5 and I had to reformat your SQL to be able to read it. The effect is unchanged btw.
Unfortunately, I suspect there's something not quite right with processing the results of a crosstab the way you have proposed. It seems to me that the crosstab would produce the sort of figures you are after without needing to GROUP by the [UserName].
Can you post in some sample data for the crosstab query so I can get a feel for the sort of data we're dealing with? Are there more than one lines for each [UserName]?
BTW, what is going on with the names of the fields in there? There are various with extra spaces, both within and at the end of field names, as well as some very unusual abbreviations that are supposed to represent months. This may not seem important now, but it will soon when we try to get the code to produce your SQL for you.
As far as the abbreviations is concerned, I had no specific reason behind it - I will write them out if you think that is a better idea.
As far as the abbreviations is concerned, I had no specific reason behind it - I will write them out if you think that is a better idea.
One more thing - the spaces indicate that no data was generated for that person for that month. Most likely because they were hired later in the year or perhaps they were on leave or some other similar thing.
Once again thank you so much!
Richard
Right, I went back to post #5 and I had to reformat your SQL to be able to read it. The effect is unchanged btw.
Unfortunately, I suspect there's something not quite right with processing the results of a crosstab the way you have proposed. It seems to me that the crosstab would produce the sort of figures you are after without needing to GROUP by the [UserName].
Can you post in some sample data for the crosstab query so I can get a feel for the sort of data we're dealing with? Are there more than one lines for each [UserName]?
BTW, what is going on with the names of the fields in there? There are various with extra spaces, both within and at the end of field names, as well as some very unusual abbreviations that are supposed to represent months. This may not seem important now, but it will soon when we try to get the code to produce your SQL for you.
Please forgive for the confusion but the department has changed its miond. They now want the data the be able to be pulled dynamically as before using the same rules as before but they are to be display in the following manner:
for a given person: -
MEQA Month
-
1 January 2008
-
1 December 2007
-
4 November 2007
-
1 October 2007
-
1 September 2007
-
3 August 2007
-
1 July 2007
-
. .
-
1 January 2007
-- They just gave me this and I am just as clueless
Richard
NeoPa 32,556
Expert Mod 16PB
Richard, I've had a horribly busy day and evening so I've been unable to catch up with all the technical posts that are outstanding.
I hope to catch up with all these posts tomorrow so please bear with me and I will respond to all you've posted.
Richard, I've had a horribly busy day and evening so I've been unable to catch up with all the technical posts that are outstanding.
I hope to catch up with all these posts tomorrow so please bear with me and I will respond to all you've posted.
No problem, That's fine - Thanks for letting me know,
Richard
NeoPa 32,556
Expert Mod 16PB
Well, it seems that grouping by UserName would be entirely redundant as there is only one record per UserName anyway.
The spaces I was talking about were the spaces within the names of the months. Access provides ways to produce various standard forms of date text which we can use if we don't have to match the format in your earlier post.
NeoPa 32,556
Expert Mod 16PB
Your source data looks interesting. - Initials MEQA Month DateReceived
-
EYL 1 January 2008 1/15/2008
-
EJW 1 January 2008 1/15/2008
-
EAN 4 June 2007 6/13/2007
-
AMN 1 June 2008 6/12/2008
-
EAN 1 June 2008 6/12/2008
-
AMN 3 March 2007 3/4/2007
-
AMN 1 March 2007 3/6/2007
-
EYL 1 March 2008 3/10/2008
-
EJW 1 March 2008 3/7/2008
I presume that the initials link into another table with the UserNames in.
I don't think I know where MEQA comes into things though. As this is involved in the new layout perhaps you could explain.
Your source data looks interesting. - Initials MEQA Month DateReceived
-
EYL 1 January 2008 1/15/2008
-
EJW 1 January 2008 1/15/2008
-
EAN 4 June 2007 6/13/2007
-
AMN 1 June 2008 6/12/2008
-
EAN 1 June 2008 6/12/2008
-
AMN 3 March 2007 3/4/2007
-
AMN 1 March 2007 3/6/2007
-
EYL 1 March 2008 3/10/2008
-
EJW 1 March 2008 3/7/2008
I presume that the initials link into another table with the UserNames in.
I don't think I know where MEQA comes into things though. As this is involved in the new layout perhaps you could explain.
Actually what would happen is that the user would select a member then a date then click find. The data would appear like this: Lets say January 2008 was picked. -
MEQA Month
-
1 January 2008
-
1 December 2007
-
4 November 2007
-
1 October 2007
-
1 September 2007
-
3 August 2007
-
1 July 2007
-
1 June 2007
-
1 May 2007
-
2 April 2007
-
1 March 2007
-
3 February 2007
-
2 January 2007
So as you can see, for every date picked, There must be a show of data that goes back 12 months. MEQA is simply a severe error commited by the user.
Hi NeoPa - Did you forget me?
NeoPa 32,556
Expert Mod 16PB
No - Not forgotten.
Things have just been really busy recently on the site. As an Admin I sometimes get tied up with less visible issues.
I will get back to this as soon as I can. Easter weekend may enable me to catch up a bit.
NeoPa 32,556
Expert Mod 16PB
Your data doesn't have a UserName included in it anywhere. Unless there is some correlation between Initials and UserName, the data cannot be selected by UserName as you suggest. - What is there that can be considered to be a unique identification in the data? Initials and Month perhaps.
- What is the data type of your fields [Month] & [DateReceived]?
- Lastly, how would the data be displayed? In a form? In a report? In a simple query window?
Clearly we need to have a query of some sort in the solution and the WHERE clause or filter (which is similar) must be designed to select only those items that you need. Without the information though, it's unclear how this can be achieved so I can't take this further just yet.
Your data doesn't have a UserName included in it anywhere. Unless there is some correlation between Initials and UserName, the data cannot be selected by UserName as you suggest.
What is there that can be considered to be a unique identification in the data? Initials and Month perhaps.
What is the data type of your fields [Month] & [DateReceived]?
Lastly, how would the data be displayed? In a form? In a report? In a simple query window?
Clearly we need to have a query of some sort in the solution and the WHERE clause or filter (which is similar) must be designed to select only those items that you need. Without the information though, it's unclear how this can be achieved so I can't take this further just yet.
The idea is that the data is selected by initials within a subreport. The initials link the child and parent form (the is how the data is given to me - username is also included but I don't think it work with the parent form.
So, the data would be displayed in a report - Month and date received should be date types. Date received is just a timestamp so it doesn't need to show on the final output - i don't know if it would be a good idea to make it part of the query - if you think it should be part then it shall be.
If you need me to clarify more information, please let me know and thanks for all your help.
Richard
PS I've reading up on PIVOT CHARTS (I have know experience on this area) do you think it be worth it to check it out?
NeoPa 32,556
Expert Mod 16PB
I've edited post #23 to display my questions in a proper, numbered list.
It appears that you've answered question #2, but #1 & #3 are still awaiting answers.
Pop the answers to those in and we'll see if we can't knock up something a little more appropriate for your needs.
I've edited post #23 to display my questions in a proper, numbered list.
It appears that you've answered question #2, but #1 & #3 are still awaiting answers.
Pop the answers to those in and we'll see if we can't knock up something a little more appropriate for your needs.
For question 1: - What is there that can be considered to be a unique identification in the data? Initials and Month perhaps.
I've been trying to figure that out myself. By that, I mean the the first table is a collection of of other tables that contain all sorts of data that is useless to me. I wrote a series of select into queries and came up with a table that looks like this: -
Initials 2_29_2008 1/31/2008 12/31/2007 etc, etc......
-
HTD 3165 4523 4043
-
KKD 2528 2662 1409
-
TKD 2204 2388 1788
-
NPF 3625 5395 3615
-
ESG 3714 4600 2487
-
CQH 2089 2919 1503
-
HNH 1895 1907 1331
-
CNH 39 246 239
-
etc.......
-
and I thought the PK would be Initials. but since te requirement is that is should be displauyed in report form in columnar form: -
Dates HTD
-
12/31/2007 4043
-
11/30/2007 1904
-
10/31/2007 2049
-
9/30/2007 1862
-
8/31/2007 2957
-
7/31/2007 3516
-
6/30/2007 3871
-
5/31/2007 4115
-
4/30/2007 3966
-
3/31/2007 3440
-
2/28/2007 2647
-
1/31/2007 3175
What I did is transform the table so that the date columns were shown horizontally and the initials were shown vertically: -
Dates HTD KKD TKD
-
2/29/2008 3165 2528 2204
-
1/31/2008 4523 2662 2388
-
12/31/20071815 4043 1409
-
11/30/2007 1460 1904 1753
-
10/31/2007 680 2049 1943
-
9/30/2007 1862 2218 1532
-
8/31/2007 2957 2102 1966
-
7/31/2007 3516 2668 617
-
6/30/2007 3871 2504 1557
-
5/31/2007 4115 2138 1720
-
4/30/2007 3966 2482 1808
-
3/31/2007 3440 3490 1105
-
2/28/2007 2647 2911 1617
-
1/31/2007 3175 1828 1952
-
I still don't know if this is a good idea or not - as far as the dates is concerned, I did not convert the full dates to months yet- I figured I can do that at the very end. In terms of a unique identifier, would the dates column be fit enough to work as a unique identifier? I am pressuming but I am not sure. What would you suggest?
3) The data would be displayed in a report.
As always, thank you so much - this is beginning to make sense for me
Richard
NeoPa 32,556
Expert Mod 16PB
Sorry Richard. I'm getting confused here a little (Question 1). Q2 & 3 are fine, but I was talking about the data laid out in my post #19 that you posted originally in post #12.
I suppose what I really need to know is "Is it possible for the initials, matched with any particular month, appear more than once?"
EG. Is the following possible (where EYL / Jan 2008 appears more than once)? - Initials MEQA Month DateReceived
-
EYL 1 January 2008 1/15/2008
-
EYL 5 January 2008 1/17/2008
-
EYL 4 June 2007 6/13/2007
-
AMN 1 June 2008 6/12/2008
This was the data source I was thinking of working with but your focus seems to be elsewhere so I'm hoping this is still valid.
If that is possible data then the query needs to have a GROUP BY clause and is complicated by aggregate functions etc. As a proponent of KISS I'm trying not to overcomplicate things.
The initials matched to a particular month cannot appear more than once. Sorry for not making it clear.
NeoPa 32,556
Expert Mod 16PB
Right, I've just skimmed through the thread to remind myself what the basic request is (we've spent a while nailing down some details) so let me see if I can outline what I think we need and you can confirm this as I look at knocking something up. If, in the mean time, you can provide any real-life names for items that I'm using that would also help.
You have a form (name) where the operator will select a user (initials) and a month.
When the command button is clicked, a query (or report) should be run to produce lines, in descending order of month, to show thirteen months of MEQA data for the user where the first record (latest month) matches the month on the form.
Names required :
Form
Control where initials entered/selected
Control where month entered/selected
Command button that triggers the query/report
Table
Fields assumed to be [Initials]; [MEQA]; [Month]
One last question is :
What is the field type of [Month]?
This is treated differently depending on whether it's a Date/Time field or a Text field.
PS. Just to clarify - the first two and the last paragraphs are the most important as far as responses are concerned. I can get by without the names (I'll invent my own) but I do need confirmation I'm on the right lines and I need to know how to deal with the [Month] data.
In terms of names for real life items I have:
Names required :
Form ....frmstats
Control where initials entered/selected.....cbInitials - the rowsource property will by a table that will fill out the combobox with initials
Control where month entered/selected - PVDate where when clicked, a calendar appears and the user selects a desired date. next to it is a non visible text box called EndDate - this textbox is populated automatically by ways of a function that picks up the date chosen from PVDate. the sql statement grabs these 2 dates as parameters and runs it.
Command button that triggers the query/report : cmdFind - when clicked, it it call the sql statement which will grab the parameters and run the query.
Table: tblHistory
Fields assumed to be [Initials]; [MEQA]; [Month] - this is correct
Month -I am presuming ought to be a date/Time type - I wonder how could the parameters work if it was to be a text field. I figure a format function for would change date date from say 3/5/2007 to March 2007 right at the textbox on the report - I hope this makes sense
NeoPa 32,556
Expert Mod 16PB
In the absense of confirmation relating to the first two paragraphs, I will continue as if you have read them and agree that they are on the button.
You talk about [PVDate] & [EndDate] controls and [EndDate] being populated from [PVDate]. If these controls have different values then this only helps if I know how [EndDate] is determined. I can only ignore [EndDate] for now and assume that [PVDate] has the value I require. - SELECT [MEQA],
-
Format(tH.Month,'mmmm yyyy') AS [Month]
-
FROM tblHistory AS tH
-
WHERE tH.Month Between CDate('1 ' & Format(DateAdd("m",-12,Forms!frmStats.PVDate),'mmmm yyyy'))
-
And DateAdd("d",-1,CDate('1 ' & Format(DateAdd("m",1,Forms!frmStats.PVDate),'mmmm yyyy')))
-
ORDER BY tH.Month DESC
The code may be considerably simpler if we know that the dates stored (as [Month]) are always stored as the first day of the month. As I don't know that I have to allow for the worst case scenario (hence the WHERE clause is so complex).
What do you think of saving the query as a report to then use it as a sub report?
by the way - A million thanks - the query works well!!!
Richard
NeoPa 32,556
Expert Mod 16PB
Firstly, you're welcome.
As to your question, I'm afraid there seems to be some confusion. As asked it doesn't make any sense. You cannot save queries as reports.
I suspect you have something more straightforward in mind, but I'm afraid I can't guess what that may be. If you can ask the question more clearly I'll happily give my thoughts on the matter.
NeoPa 32,556
Expert Mod 16PB
WOW!!!!!!! It works!!!
I will talk with the other admins about making it a sackable offense to express any surprise when my solutions work in future.
It's as if no-one has any confidence in me :(
(LOL)
I will talk with the other admins about making it a sackable offense to express any surprise when my solutions work in future.
It's as if no-one has any confidence in me :(
(LOL)
I always had total and complete faith in you -I was very excited that It is working. I am trying to figure out a way to put the results of the query as a subreport. :)
NeoPa 32,556
Expert Mod 16PB
Of course.
And I'm sure you know I was just kidding around :)
Of course.
And I'm sure you know I was just kidding around :)
I presumed that
I have another question, if i need to list every month that does not have a value or is not on the data but must include a value of 0 for that month, how would I go about it?
NeoPa 32,556
Expert Mod 16PB
This is not very straightforward in SQL :(
Essentially what you need to do is have a record source (Let's call it tblDates for this illustration) which would be treated as the master table and must contain all the dates you need to show, then link it to your other data with a LEFT JOIN.
There are two main difficulties with this approach : - The linked fields must be identical, so the [Month] field in your [tblHistory] table MUST be consistent and predictable (easiest is to ensure always the first day of the month).
- Providing a record source that has all the dates you need for whatever frmStata.PVDate is, is a very complicated issue.
NeoPa 32,556
Expert Mod 16PB
Let's start with confirming that the [Month] value and the [PVDate] value ALWAYS reflect the first day of the month.
I'm going one step at a time as there is no danger of skipping important steps or questions that way.
Let's start with confirming that the [Month] value and the [PVDate] value ALWAYS reflect the first day of the month.
This is no problem. I receive the data dumps in excel and they leave it to me to prepare the data as I see fit so the Month value and the PVDate will ALWAYS be the same. I pick the columns that are needed for this project and incorporate them into the table. What they care about is months so I will make sure both values are the same.
This is not very straightforward in SQL :(
Essentially what you need to do is have a record source (Let's call it tblDates for this illustration) which would be treated as the master table and must contain all the dates you need to show, then link it to your other data with a LEFT JOIN.
There are two main difficulties with this approach :- The linked fields must be identical, so the [Month] field in your [tblHistory] table MUST be consistent and predictable (easiest is to ensure always the first day of the month).
- Providing a record source that has all the dates you need for whatever frmStata.PVDate is, is a very complicated issue.
I kinda figured that it would be no easy task. The tblDates table would have a PK, and a field with Dates in month format, correct? does that mean that every row of individual dates need to be converted to the 1st dat of the Month - that is VERY POSSIBLE- my bosses only care about Months not specific dates...
NeoPa 32,556
Expert Mod 16PB
This is no problem. I receive the data dumps in excel and they leave it to me to prepare the data as I see fit so the Month value and the PVDate will ALWAYS be the same. I pick the columns that are needed for this project and incorporate them into the table. What they care about is months so I will make sure both values are the same.
As long as you can ensure that all dates are stored as the first of the month (As Access stores month dates anyway) then we're good.
Next we need to create a table called [tblDate] as follows : - Table Name=[tblDate]
- Field; Type; IndexInfo
-
DateOffset; Numeric; PK
This table needs to be populated with [DateOffset] values of 0 through -12 (13 records).
This may seem a little weird, but it will become clearer when we use it.
NeoPa 32,556
Expert Mod 16PB
...The tblDates table would have a PK, and a field with Dates in month format, correct?...
No. As per my previous post (#43) the data is simply a DateOffset value which is itself the PK.
...Does that mean that every row of individual dates need to be converted to the 1st dat of the Month - that is VERY POSSIBLE- my bosses only care about Months not specific dates...
If you have any date values stored in your [Month] field that are NOT the first of the month then yes.
FYI: If you run this code you will get the result shown : - MsgBox Format(CDate("November 2008"),"d mmmm yyyy")
-
1 November 2008
This is the default date Access assumes if you leave out the day number and just use the month.
NeoPa 32,556
Expert Mod 16PB
The last step is to change the SQL of your query to : - SELECT tH.MEQA,
-
Format(subD.Month,'mmmm yyyy') AS [Month]
-
FROM (SELECT DateAdd('m',[DateOffset],Forms!frmStats.PVDate) AS Month
-
FROM tblDate) AS subD LEFT JOIN
-
tblHistory AS tH
-
ON subD.Month=tH.Month
-
ORDER BY subD.Month DESC
The last step is to change the SQL of your query to : - SELECT tH.MEQA,
-
Format(subD.Month,'mmmm yyyy') AS [Month]
-
FROM (SELECT DateAdd('m',[DateOffset],Forms!frmStats.PVDate) AS Month
-
FROM tblDate) AS subD LEFT JOIN
-
tblHistory AS tH
-
ON subD.Month=tH.Month
-
ORDER BY subD.Month DESC
I am not getting any values on the MEQA field
NeoPa 32,556
Expert Mod 16PB
Post in what all your settings are (the value of the PVDate control; The actual results of the query etc) and we'll see what might be missing.
PS. Include the data of the relevant records in tblHistory too, showing all dates completely.
Post in what all your settings are (the value of the PVDate control; The actual results of the query etc) and we'll see what might be missing.
PS. Include the data of the relevant records in tblHistory too, showing all dates completely.
for PVDate I have entered 2/28/2008,2/1/2008, and february 2008 with nothing showing in the MEQA column - these are results: -
MEQA Month
-
-
February 2009
-
January 2009
-
December 2008
-
November 2008
-
October 2008
-
September 2008
-
August 2008
-
July 2008
-
June 2008
-
May 2008
-
April 2008
-
March 2008
-
February 2008
Here are the records from tbl history: -
-
DateReceived Month Initials MEQA
-
-
1/6/2007 January 2007 DKS 13
-
1/9/2007 January 2007 KKD 7
-
1/9/2007 January 2007 YRM 4
-
1/10/2007 January 2007 CNH 6
-
1/12/2007 January 2007 RBD 1
-
1/16/2007 January 2007 HKT 6
-
2/16/2007 February 2007 JPT 7
-
3/18/2007 March 2007 YRM 14
-
3/18/2007 March 2007 RRS 4
-
4/19/2007 March 2007 KKD 13
-
4/23/2007 March 2007 KEL 1
-
-
etc
-
i hope this information is clear
thanks again,
Richard
NeoPa 32,556
Expert Mod 16PB
Richard, this indicates to me that you haven't followed the instructions in post #43 quite correctly.
The numbers should be 0 through (minus)12.
To fix this without redoing the table data, just add a - (minus) before the [DateOffset] bit in line #3 of the latest SQL code. - FROM (SELECT DateAdd('m',-[DateOffset],Forms!frmStats.PVDate) AS Month
Let me know how it goes after that.
Richard, this indicates to me that you haven't followed the instructions in post #43 quite correctly.
The numbers should be 0 through (minus)12.
To fix this without redoing the table data, just add a - (minus) before the [DateOffset] bit in line #3 of the latest SQL code. - FROM (SELECT DateAdd('m',-[DateOffset],Forms!frmStats.PVDate) AS Month
Let me know how it goes after that.
Good Morning, Here's what I get when I enter 2/1/2008: -
-
MEQA Month
-
February 2008
-
January 2008
-
December 2007
-
November 2007
-
October 2007
-
September 2007
-
August 2007
-
July 2007
-
June 2007
-
May 2007
-
April 2007
-
March 2007
-
February 2007
-
The MEQA field still shows nothing. Would it be feasible to perhaps use this newly created query and join it with tbl History again? I'll give it a shot--
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kevin |
last post by:
I don't know if I should even start this topic but here goes.
I'm an ex vb6 developer, now developing in C#.
The reason why I started developing in C# is because the company that I
worked for at...
|
by: Bazza Formez |
last post by:
Hi there,
For some reason, when I edit row in my datagrid, some columns have (an
unwanted) back color of yellow, while others correctly display with white
back color.
I can see no setting in...
|
by: Terry Olsen |
last post by:
I've got my datgrid loaded (finally). I can select rows & delete them.
But I can't select columns to delete them. When I click on a column
header, all that happens is the grid is resorted by that...
|
by: monomaniac21 |
last post by:
hi all
im trying to write a pdf document which contains two columns of data.
when the column on the left crosses over to the next page i need to be
able to go back afterwards to the previous...
|
by: hime |
last post by:
Hello
I have a data entry web App. form. the login page for this form depends on checking whether the user name and password exists in the data base or not only; which means that I didn't use...
|
by: toglez |
last post by:
Hi all!
I use PyQt4 and Python to create a program to display numbers from a file in a QTable Widget, select various columns from the table and then display the selected columns in a new table.
...
|
by: Rickster66 |
last post by:
This thread is similar to the thread (Select only 10 columns going back) that I posted regarding the dynamic selection of data going back one month at a time for 12 months. Here is the qiote fron...
|
by: Rickster66 |
last post by:
As Instructed this is a new thread regarding my original post: "Select Only 10 Columns Going Back"
I'm sorry for the late response. I've been gathering up information and carefully with as much...
|
by: adarshyam |
last post by:
friends,
i have a problem in going back to previous page in my application.. since i want that to happen in the if else statement i cannot incorporate JS. please help me .. i am trying this...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
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,...
|
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,...
| |