|
-
Nov 2nd, 2005, 11:31 AM
#1
Thread Starter
Addicted Member
Where's the error?
Is there anything wrong with this function? Whenever I call it, I get an error saying "Wrong number of arguments or invalid property assignment" with the Day function highlighted...
Code:
Private Function DaysInMonth(iMonth As Long, iYear As Long) As Integer
DaysInMonth = Day(DateSerial(iYear, iMonth + 1, 0))
End Function
... it looks okay to me. This is code running under VBA in MS Access if that makes a difference.
Using Visual Studio .NET 2005
-
Nov 2nd, 2005, 11:56 AM
#2
Re: Where's the error?
Here's my version of this function.
VB Code:
Function DaysInMonth(MthNum As Integer, YrNum As Integer) As Integer
Dim dtTemp As Date
dtTemp = DateSerial(YrNum, MthNum, 1)
DaysInMonth = DateAdd("M", 1, dtTemp) - dtTemp
End Function
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Nov 2nd, 2005, 12:02 PM
#3
Re: Where's the error?
Works Fine when i run it !!, what version of Access are you using ?
I don't see any reason why this shouldn't work to be honest !
-
Nov 2nd, 2005, 12:33 PM
#4
Re: Where's the error?
Worked just fine for me as well.
-
Nov 2nd, 2005, 12:56 PM
#5
Frenzied Member
Re: Where's the error?
Do you have the reference set to use Day()? What's the error?
Tengo mas preguntas que contestas
-
Nov 3rd, 2005, 06:03 AM
#6
Thread Starter
Addicted Member
Re: Where's the error?
 Originally Posted by salvelinus
Do you have the reference set to use Day()? What's the error?
Erm... maybe. How can I check for that? I replaced the function with DKenny's version and that seems to work. I'm pretty sure I had used the Day function before though, and it worked then...
Using Visual Studio .NET 2005
-
Nov 3rd, 2005, 08:13 AM
#7
Frenzied Member
Re: Where's the error?
In the VBE, Tools-References and check Microsoft DAO 3.6 Object Library (at least I think that's the correct one, according to the Object Browser)
Tengo mas preguntas que contestas
-
Nov 3rd, 2005, 09:24 AM
#8
Thread Starter
Addicted Member
Re: Where's the error?
Yeah, it's selected so I'm not sure the problem is.
This isn't related (or at least I don't think so) but I doubt it's worth creating a new topic for. Apparently the Range object (used for a spreadsheet control) has a resize function...
Code:
'Get the range of the current table
Dim tableRange As Range
Set tableRange = Sheet.Cells(1, 1)
Set tableRange = tableRange.Resize(m_dimX, m_dimY)
.. however, whenever I run that I get 'Method or data member not found'. I figured I might as well post it here since, again, it seems to be VBA not finding something it should (whether it be a function or a method).
This isn't going well at all...
Using Visual Studio .NET 2005
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|