Day() function - fine in one form, Error 2465 on another.

H

Helen

Two forms need command buttons to do the same thing. The code was working
perfectly on one form, so copied it over to the other.

Get error 2465 = Can't find the field 'Day' in your expression.

Relevant code:
Dim Default as date
Dim DDay as integer

Default = Int(Now())
DDay = Day(Default) --------------this line is highlighted by the debugger

If today is the 15th of May, one form works fine: Default = 15/5/09, DDay = 15
The other form gives the error. Default shows as above, but "Day(Default)"
in the watch zone shows the error. There is no field called "Day" on the
second form.

I'm perplexed.
 
J

Jack Leach

I'm not sure if this is the problem or not, but just out of curiousity, why
use int() instead of standard a standard date or format function?

Also, I would guess that Default is a reserved word.

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
H

Helen

Thanks for the quick reply!
I've taken to using Int(Now()) in place of Date() because when I gave the
file to a friend, Date() didn't work. Poked around the forums and found that
others had the same problem - Now() worked fine, but Date() didn't. The
advice realted to referencing errors which was really ugly to fix, given that
the friend is in another country. Using the Int solved THAT problem very
simply.

'Defatult' doesn't seem to be the problem (but I can easily change that to
check), as when I put a watch on the value of Default, it's as it should be -
today's date, with format 'Date'. The debugger hangs up on the Day function
- seeking a field instead of just doing the function.
 
J

Jack Leach

Sorry, nothing else is ringing any bells.

Hopefully someone else can see something that I'm not.

You don't have any controls or fields named Day do you?

gl
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
J

John W. Vinson

Two forms need command buttons to do the same thing. The code was working
perfectly on one form, so copied it over to the other.

Get error 2465 = Can't find the field 'Day' in your expression.

Relevant code:
Dim Default as date
Dim DDay as integer

Default = Int(Now())
DDay = Day(Default) --------------this line is highlighted by the debugger

Helen, I'm suspecting that this is another symptom of the missing reference
which is probably also causing the problem with Date().

Open the VBA editor. On the menu select Tools... References. What lines are
checked? Are any of them marked MISSING? If so, uncheck that reference, select
Debug... Compile and see if these problems resolve.
 

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