I took the following function code from an articl "How to: Find the Number of Days in a month in Access 2000. Problem is, when I try to test it like they say:
"In the immediate window type ?DaysInMonth(Date())"
I get a visual basic "Run-time error '13': Type mismatch" error.
Function DaysInMonth(Mydate)
' This function takes a date as an argument and returns
' the total number of days in the month.
Dim NextMonth, EndofMonth
NextMonth = DateAdd("m", 1, Mydate)
EndofMonth = NextMonth - DatePart("d", NextMonth)
DaysInMonth = DatePart("d", EndofMonth)
End Function
I also tried this, with the same resulting error.
Function DaysInMonth(Mydate As Date) As Integer
' This function takes a date as an argument and returns
' the total number of days in the month.
Dim NextMonth As Date, EndofMonth As Date
NextMonth = DateAdd("m", 1, Mydate)
EndofMonth = NextMonth - DatePart("d", NextMonth)
DaysInMonth = DatePart("d", EndofMonth)
End Function
Any ideas?
"In the immediate window type ?DaysInMonth(Date())"
I get a visual basic "Run-time error '13': Type mismatch" error.
Function DaysInMonth(Mydate)
' This function takes a date as an argument and returns
' the total number of days in the month.
Dim NextMonth, EndofMonth
NextMonth = DateAdd("m", 1, Mydate)
EndofMonth = NextMonth - DatePart("d", NextMonth)
DaysInMonth = DatePart("d", EndofMonth)
End Function
I also tried this, with the same resulting error.
Function DaysInMonth(Mydate As Date) As Integer
' This function takes a date as an argument and returns
' the total number of days in the month.
Dim NextMonth As Date, EndofMonth As Date
NextMonth = DateAdd("m", 1, Mydate)
EndofMonth = NextMonth - DatePart("d", NextMonth)
DaysInMonth = DatePart("d", EndofMonth)
End Function
Any ideas?