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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't find year expression

Status
Not open for further replies.

Costefran

Technical User
Jan 2, 2008
197
0
0
GB
Can anyone help

I have the following code in my form on current as I am trying to set my control "Year of Application" to the current year. However I get the message 'microsoft access can't find the field 'YEAR' refered to in your current expression

Forms![Cost Authorisation Preparation Form]![Year of Application] = YEAR(Now())

Once again any help would be appreciated

 
RobertT687

Am not entirely sure what you mean (are you saying that all controls should reference the underlying table / query?

I can say that if I change the code to

Forms![Cost Authorisation Preparation Form]![Year of Application] = 2008

the form works fine
 
G'day Costefran,

Nope, Rob means to check your reference libraries in VBA. To do this open any code window and then click on the Tools menu. Select References. In the References window the top few entries, such as Visual Basic for Applications, Microsoft Access 11 object library, etc should be ticked.

Check to see if anything with a tick has the word "MISSING" next to it. If it does then you'll need to either locate the library (Browse) or untick the check mark.

Your code will hopefully compile and execute then.

JB
 
Try:

Forms![Cost Authorisation Preparation Form]![Year of Application] = vba.YEAR(Now())
 
Thanks

I have deleted the existing control on the form and replaced it by dragging from the field list and it seems to work

Once again thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top