Dateserial function

C

Chieko Kuroda

hello,
I am trying to determine the first day of the current month using
curday = DateSerial(Year([FirstDate]), Month([FirstDate], 1) 'first day of
month
the [FirstDate] is a field in my form formatted to short date and a default
value of date(),
and curday is a date value ie. 'dim curday As Date'.
Everytime I run the function the form stops and tells me that I have and
invalid data type at the month function.

While I'm in the vb designer in the debugger mode when I hover over 'year'
with the cursor nothing pops up, but when I hover over 'month' I get
"Month=<invalid datatype>".
Does anybody know how to correct this error?
Chieko
 
R

Rick Brandt

Chieko Kuroda said:
hello,
I am trying to determine the first day of the current month using
curday = DateSerial(Year([FirstDate]), Month([FirstDate], 1) 'first day of
month
the [FirstDate] is a field in my form formatted to short date and a default
value of date(),
and curday is a date value ie. 'dim curday As Date'.
Everytime I run the function the form stops and tells me that I have and
invalid data type at the month function.

While I'm in the vb designer in the debugger mode when I hover over 'year'
with the cursor nothing pops up, but when I hover over 'month' I get
"Month=<invalid datatype>".

If what you have posted here is an exact copy of your code you have a
missing closing parenthesis before the final comma.


Instead of...
DateSerial(Year([FirstDate]), Month([FirstDate], 1)

It should be...
DateSerial(Year([FirstDate]), Month([FirstDate]), 1)
 

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

Similar Threads

Calendar Question 6
Too Many Dates 1
Default value 4
DateFields 0
Date Time decimal value help please 1
Mid-Month function help 5
displaying records on subform 2
IIF with Dateserial and Between 2

Top