mdnuts
Registered User.
- Local time
- Today, 11:10
- Joined
- May 28, 2014
- Messages
- 128
I'm following this
which works fantastically if I put in what the example says to
But I need to set that dynamically. DateSerial part is no problem, it is the vb(Dayofweek) and the Nth of that day that I cannot get to work.
Breaking it out like this.
The above is selected by the user who picks 1st, 2nd, 3rd, 4th in one drop down and Monday, Tuesday, etc in another drop down on the form.
What I get in error is
As reference - here is the function declaration used
Any ideas?
which works fantastically if I put in what the example says to
Code:
to call ? NthXDay(dateserial(year(date), 1, 1),vbMonday, 3)
Breaking it out like this.
Code:
strMonthDay = "vb" & Me.cboMonthDay
strMonthWeekNum = Int(Left(Me.cboMonthWeekNum, Len(Me.cboMonthWeekNum) - 2))
MsgBox NthXDay(DateSerial(Year(Date), Month(Date), 1), strMonthDay, strMonthWeekNum)
What I get in error is
Which tells me it is passing as a string and needs to pass as something else - such as Integer. I've tried dim the two variables as integer and they just give a type mismatch.ByRef argument type mismatch
As reference - here is the function declaration used
Code:
Function NthXDay(pdate As Variant, pWDay As Integer, _ pIncrement As Integer) As Date 'coded by: raskew