Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dtpicker 2

Status
Not open for further replies.

Lhuffst

Programmer
Jun 23, 2003
503
US
Requirements require me to display only month and day not month/day/year. Also wants default to be last month. Have that part fine in code but when I try to run form, I get an error occured in the call to windows date and time picker control. I used the following code in on form open

Dim LastMonth
'LastMonth = Now() - 30
LastMonth = Format(Now() - 30, "MM/DD")

Debug.Print LastMonth
DtDateFrom.value = last month

I also tried reformatting the date to make sure it passed as a string but received same error msg.

DtDateFrom.Value = Format(LastMonth, "mm dd")
 



Hi,
Code:
LastMonth = Format(Now() - 30, "MM/DD")
Format returns a STRING, not a date.

Your table probably wants a DATE. Does not matter how the date is FORMATTED in the table, ROEMAT when you REPORT.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Am I missing something here - what day do you need to be displayed? If now() is 31st January then now()-30 is 1st January.
Isn't this the code you want for today's date last month?
[blue] Format(DateAdd("m", 1, Now()), "mm/dd") [/blue]
Simon Rouse
 
Whoops that should have been
[blue]Format(DateAdd("m", -1, Now()), "mm/dd") [/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top