Month function not working on form

J

Julia B

Hi

I've got a problem on one of my forms. I want to work out what the current
month is so I'm doing this:

Dim currentmonth as Integer
currentmonth = Month(Date)

This was originally causing a datatype mismatch error. I discovered it was
because I foolishly had a field called Month in the underlying table and
Access was trying to reconcile with that. I've renamed the field, and now I
get the error "Access can't find the field 'Month' referred to in your
expression".

Duh, of course it can't find the field! It's a function..... how do I get
over this? Any ideas?

Thanks

Julia
 
J

Jeff Boyce

Julia

There are a number of "reserved words" in Access that you don't want to use
for fieldnames, mainly because it confuses both you and Access about which
"Month" you mean.

The solution is to change the name of the field to something that isn't
reserved...

I'm curious, though, why you are storing a "month" value? If you already
capture a date/time value in each record, you can use that Month() function
to derive the month!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Julia B

Yes, I realised that and have changed the name of the underlying field before
I posted the original problem. This problem happened after I changed the
field name.

In answer to your second question, I need to get the current actual month,
not stored month, hence Month(Date).

Julia
 
J

Julia B

Jeff, thanks for the response, but it's fixed itself without me doing
anything. I think Access must have got itself in a muddle and when I
restarted my PC this morning it's all working fine.

Thanks anyway.

Julia
 
J

Julia B

Julia B said:
Hi

I've got a problem on one of my forms. I want to work out what the current
month is so I'm doing this:

Dim currentmonth as Integer
currentmonth = Month(Date)

This was originally causing a datatype mismatch error. I discovered it was
because I foolishly had a field called Month in the underlying table and
Access was trying to reconcile with that. I've renamed the field, and now I
get the error "Access can't find the field 'Month' referred to in your
expression".

Duh, of course it can't find the field! It's a function..... how do I get
over this? Any ideas?

Thanks

Julia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top