for the combo box "MNo":
What is the Record Source?
SELECT Months.ID, Months.MNo FROM Months;
(a separate table with 2 columns, ID & MNo - only 12 records for 12 months
with IDs 1-12)
What is the bound column? 1
What is the column count? 2
What is the column widths? 0cm;2.54cm
What is the table structure for the table that holds the month info?
Field name - field type
------------------------------
Operation Date - Date/Time
Paid to - Text
Amount - Number
Reporting Date - Date/Time
I tried to change original
WHERE (((Month([Reporting Date]))<(Val(Format(Forms!Main!MNo), "mm")+1)));
to:
WHERE (((Month([Reporting Date]))<=([Forms]![Main]![MNo])));
Seems to work, but only with months 1-9. When comes to 10,11,12 - gives out
wrong data.
Also, the Where clause will select all months less than or equal to the
month entered in the combo box for ALL years. If you had 5 years of data
(1999 - 2004) and you wanted months Jan - May, you would get Jan - May for
1999, Jan - May for 2000, ..., Jan - May for 2004. Maybe that is what you
want...??
Frankly speaking I am in a great mess right now! I have about 15 querries
which do the calculations I need. And lots of them depend on that MNo field.
One of them looks like:
WHERE (((Month([Operation Date]))<=(Forms!Main!MNo) And (Year([Operation
Date]))<((Year(Date()))+1)));
I guess this one also is not correct.
I would be happy to reduce the number of queries but don't know how. I need
sub-queries like "Sums" and "Totals" and I dont know any other way but to put
them into separate queries and then reffer to that queries. I didnt succeed
with the names of the queries so now I am completely lost in them now!
Probably will have to change everything.
Basically, I need 4 of them:
1) calculating "Previous" - the amount of money I have at the begginning of
the reporting month ([sum of received till date]-[sum of spent till date])
2) retrieve all records from "Received" for this month
3) retrieve all records from "Spent" for this month
4) get the amount of money "Hanging" (not reported) - this comes
complicated. I need to look for "Operation date" and "Reporting date". I
don't add to the "Hanging" amount those records where reporting was done
before the needed month. But I do add them if the reporting was done, but
later than this needed month. And here I also need to take the year into
consideration - cause nobody ever does reporting in time. (For received-spend
things I decided to start new database each year, only keeping the table with
"Hanging" amounts from previous.)
So for the "Hanging" I would like to have all months for the previous years
and all months for this year up to the end of the month I need. (E.g. since
Jan. 1, 1900 till May 31, 2004).
How can I achieve this if I enter only the Month into my combo-box and
assume the Year is (). I hope it will work all right even for retrieving the
last year records since I keep the new year ones in a separate DB?
One more question: I have put the following into the default value of my
combo-box as you advised:
=Format(Date(),"mmmm")
It displays "November" all right on open, but doesn't work to retrieve the
records for this month.
When I try to select value from the list, it sais "the value you entered is
not valid for this field". I click OK, then select from my list the same
"November" month, click "refresh" and all the records appear all right.
Why does this happen? Why it doesn't accept the default?
Lana