Setting field values on form load

stuart_adair

Registered User.
Local time
Today, 14:12
Joined
Jan 13, 2009
Messages
57
Hello all,

I have a field called "date raised" in a database.

When a particular form opens I want a field called month to be set to the month number of the date raised field.

I've gone into the form properties box, On Load, event procedure and entered this...

Month = Month ([date raised])

But this gives me a compile error

Help please !!!

Stu
 
Hello all,

I have a field called "date raised" in a database.

When a particular form opens I want a field called month to be set to the month number of the date raised field.

I've gone into the form properties box, On Load, event procedure and entered this...

Month = Month ([date raised])

But this gives me a compile error

Help please !!!

Stu
Where in the database is "date raised" stored? Your post doesn't give a clue.

What record are you trying to apply Month = Month ([date raised]) ?

Doing it in the OnLoad event will only place it in the first record that appears.

And you absolutely have to change the name of the field Month! It's a reserved word and shouldn't be used as a control/object name. Just looking at what you've written should tell you that!
 
Also, basing a field update upon another field? That is a bit of a no, no as you can't guarantee that the value will remain valid should one of the field values change outside of your code structure. Now, in Access 2010 you will be able to do that using a calculated field or a data macro. But right now, your data integrity is not guaranteed with doing this.
 
Thanks for the replies.

Both fields "date raised" and "month" are stored within the same table on the database.

Stu
 
Thanks for the replies.

Both fields "date raised" and "month" are stored within the same table on the database.

Stu

Stu:

At this point it is best if you don't store the value but get it in a query when you need it. Build yourself a base query which is just like the table but has that extra field and then you can use that base query as a substitute for each place you would normally use the table.
 
I'm with you now. I actually want to extract the month so that I can build a crosstab query that displays the month of date raised on the left, a status field at the top and a cost field as the data. All fields exist within the same table and are called.
-date raised
-status
-cost

I've build plenty of crosstabs but always using the wizard - I'll have a play and see if I can get this to work.
Stu
 

Users who are viewing this thread

Back
Top Bottom