Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with "month" field please

Status
Not open for further replies.

Keetso

Technical User
Nov 18, 2003
49
CA
Hi.

I have an Access 2000 database which tracks finncial brokers and their commissions.

Up to now everything has worked fine but the client has called and wants me to "fix" a limitation on report generation. I think my question will make better sense if I give a brief synopsis of how a broker's commission information is entered now and how it needs to be modified.

Currently, a broker's commission transactions are entered via form/subform and all calculations are working perfectly. In order for the end user to print monthly reports, etc, each transaction entered is date stamped with the current date and a "month" field captures the numerical equivalent of this datestamps month using the "DatePart" function. Report queries then use the "month" field to select the correct records for printing.

The client has stated that on some months she will be entering , for example, "April" transactions during the first week of May due to a high volume of transaction activity. Unfortunately, those transactions entered during the first week of may would be reflected on May's report and not April's since the date stamp be 05/??/2004.

For example,

On February 4th, the end user needs to enter 10 broker transactions. 6 of these are "February" transactions and he/she enters them as normal. Since the combo box has the current month as default, the end user just tabs past this combo box and the "month" field would be populated with the number 2 (corresponds with the current month of February). These transactions would then be included in the February reports. The next 4 transactions are "January" transactions, so the end user would enter the transaction information as normal and change the "Which month do you want to include this transaction in" combo box to "January". This now populates the "month" field with a 1 (corresponding to January) and would then be included in January's reports.



In order to fix this and not have to change a ton of underlying report queries that use a numerical "month" field corresponding to the months of the year (1-12), I created a combo box on the form that lists the months of the year (with the current month set as a default) to allow the end user to select which month that transaction should be included. I created an event in the "After Update" section of the combo box that uses a SELECT statement to look at which month was selected and place it's corresponding numerical equivalent into the table's "month" field. Thus, the datestamp would remain the current date, but the "month" field would have the numeral corresponding to the month selected. The SELECT statement looks as follows:

SELECT cboxmonth
CASE "January"
Me.month = 1
CASE "February"
Me.month = 2
ETC
ETC
ENDCASE

The problem is that the "month" field is not being populated and I'm getting the following error message:

"The field 'tblbrokermonthlydata.month' cannot contain a NULL value because the required property for this field is set to true. Enter a value in this field."

For some reason the value from the case statement isn't being passed to the field.

Does anyone have any suggestions as to what might be the problem?

(Sorry for the wordy explaination)

K.
 
Are you sure that at the time the event is called, the value of cboxmonth is what is should be?

I would use Debug to set the select line in your code as a brake point, and add a watch to the value. See if that yields any clues. Likely, the value is not matching any of the Case requirements.

ChaZ

Ascii dumb question, get a dumb Ansi
 
The code itself should work. The only way I could see you getting that error is if the Month field is not bound to a a field in the underlying record source. Look in the control source property of the month field to ensure it's tied to a field in the record source. You may also want to delete the control and drop it back on from the field list to make sure.
 
Hi.

Sorry for the reponse "lag". Had to go out of town on an emergency.

Just a quick update. The "month" field is now populating correctly. Everything seemed to work great until I generated the report.

All the correct broker entries are showing up in the report (end-user uses a parameter to type in the month that they want to have on the corresponding "monthly" report and all numbers are calculating correctly.

The problem now is that those brokers who have more than one entry are now showing up in the report on separate lines. Before I made this change, all entries were summed. I know it usually happens when you don't "sum" a query field, but this is a text field and is identical to the others.

Any idea why this might be happening?

Again, many TIAs!

K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top