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

Date problem

Status
Not open for further replies.

lixtifur36

Programmer
May 27, 2005
5
US
Hello,
I am having a problem with an Access Application that I have created. The program works fine on some machines and on others it crashes, pointing to a line of VBA code (sDate.text = Date -365). It highlights the word "Date" and a message box comes up saying "Compile error: can't find project or library". Can anyone please help

Thank you

 
What is the code suppose to be doing? Per stix4t2, do you want to access the current date? or current date - 365 days?

Remember when... everything worked and there was a reason for it?
 
How are ya lixtifur36 . . .

Since you've specified the [blue]Text property[/blue] for sDate, Access has to attempt ro coerce Date (aka that stated by [purple]stix4t2[/blue] as the date function [blue]Date()[/blue]) into a string, as DATE() is a numeric value.

To cut it short . . . try:
Code:
[blue]    (Me!sDate = Date() -365).[/blue]

Calvin.gif
See Ya! . . . . . .
 
That it only fails on some computers, seem to indicate some reference problems. Check to see if some is marked as "missing", "invalid" ...

Could it perhaps be that you've used the reserved word "Date" as name of an object/variable ...? If so - well, really you should avoid that t;-)

... but a workaround is prefixing the function with the library it belongs to.

[tt]me!sDate.Value = VBA.Date()[/tt]

Roy-Vidar
 
Compile error: can't find project or library
Seems like a reference issue.
When in VBE (Ctrl+G) menu Tools -> References ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top