Type mismatch

A

AFelectrician

My module opens a form and allows the start date to input into the start of
schedule to begin. When I enter any date in the correct format it give a
type mismatch error. Here is the funtion of my module
Function SetStartDate()
GlobalStartDate = InputBox("Enter the Report Start Date (DD Mmm YYYY).
Return for Today", "Personnel Availability", Format(Now, "dd mmm yyyy"))
SetStartDate = GlobalStartDate

End Function
What am I doing wrong, I am new to this so I just might overlooking something.
 
J

John Spencer

Your code works to return a string value that looks like a date. If you
want a date value then you will need to convert GlobalStartDate to a date.

I would change your code. Also, you didn't declare GlobalStartDate in the
function. Is it declared elsewhere as a date variable or a string variable?

Function SetStartDate()
GlobalStartDate = InputBox("Enter the Report Start Date (DD Mmm YYYY).
Return for Today", "Personnel Availability", Format(Now, "dd mmm yyyy"))

If IsDate(GlobalStartDate) = True then
SetStartDate = CDate(GlobalStartDate)
Else
SetStartDate = Null
End If

End Function
 
A

AFelectrician

It is declared in several locations. I did fix the the type mismatch but it
wasn't this. I had to hold the information elsewhere in the module to set
the start date.
Thanks for looking at this.
 

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