Cdate problem (1 Viewer)

rickyfong

Registered User.
Local time
Today, 11:56
Joined
Nov 25, 2010
Messages
199
TDAY = CDate("STR(Me.Combo25) & " - " & Me.Combo21 & " - " & STR(S1)")
OR
TDAY = CDate(STR(Me.Combo25) & " - " & Me.Combo21 & " - " & STR(S1))


I have tried both, but both were not working!! Any help ?? ThankS!

Me.COMBO25 and S1 are TEXT data and Me.COMbo21 is numeric data!
 

MarkK

bit cruncher
Local time
Today, 11:56
Joined
Mar 17, 2004
Messages
8,181
CDate() requires a valid date as input, so for safety in your code, check the input value first with IsDate(), like . . .
Code:
dim tmp as string
tmp = Me.Combo25 & "-" & Me.Combo21 & "-" & me.S1
If IsDate(tmp) then TDAY = CDate(tmp)
And for valid date formats, print dates to the immediate pane and see what you get, like . . .
Code:
? Format(Now(), "Medium Date")
 17-Mar-16
. . . so now if you want to push a string date value into a function, format it like that: dd-mmm-yy.
Code:
? IsDate("17-Mar-16")
 True
Hope this helps,
 

rickyfong

Registered User.
Local time
Today, 11:56
Joined
Nov 25, 2010
Messages
199
It's the problem of space!! Now is working well!Thanks a lot!!
 

Grumm

Registered User.
Local time
Today, 20:56
Joined
Oct 9, 2015
Messages
395
Why try to make a date like that ?
If you have 3 different fields you can do this :
Code:
TDAY = DateSerial(Me.Combo25,Me.Combo21,STR(S1)

(You still need to test off course the values are valid.)
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 19:56
Joined
Sep 12, 2006
Messages
15,658
why do you have 3 separate boxes to generate a date? Why not use a date picker of some sort? or just a single date entry text box?
 

Users who are viewing this thread

Top Bottom