Raspberry
Raspberry

Reputation: 63

Type Mismatch when Calling Month on a valid date

I am having an issue with Ms Access 2010 processing Dates using the Month and Year functions. Oddly enough the day function works...

?Day(#12/25/2014#)
 25 
?Month(#12/25/2014#)
 error
?Year(#12/25/2014#)
 error

The error I am getting is a Run-time Error '13' / Type Mismatch. An help diagnosing he root cause or a solution would be appreciated.

Upvotes: 0

Views: 1052

Answers (1)

Tom Robinson
Tom Robinson

Reputation: 1930

I suspect Month and Year have been redefined in your code.

Try typing just the 7 characters ?month( into the debug window without pressing Enter, and see what the IntelliSense tip pops up with.

If it says Month(Date) then all is working fine.

If it says something like Local Month As Variant then that is what you need to fix.

This code reproduces your problem, complete with the same error message:

    Public Sub MonthFail()
    Dim Month, x
    x = Month(#12/25/2014#)
    End Sub

Upvotes: 2

Related Questions