I am trying to get a date from an input box. Obviously it returns a string, how can I get this to be changed to a date to allow it to be added into a date field in a insert query that creates a new record?
Do I have to go through a variant varaible? Any hints?
Use the CDATE function. Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
Thanks, I actually have been working with this
the code is here
strStatus = "Open"
strInput2 = InputBox(Prompt:="Please add the Date of Failure. It is necessary to create a new record.", Title:="Add the Date Of Failure"
dtFailure = CDate(strInput2)
strSQL = "INSERT INTO tblNCProduct ([TrackingNumber],[LotNumber],[PartNo],[AccessCreatorStamp],[Status],[FailureDate],[CreateDateTimeStamp]) VALUES ('" & strInput & "','" & strLotNumber & "','" & strPartNumber & "', '" & strUser & "', '" & strStatus & "',' # dtFailure # ', Now() );"
The watch feature tells me that the variable is changing to date but is now being called into my insert into statement
"INSERT INTO tblNCProduct ([TrackingNumber],[LotNumber],[PartNo],[AccessCreatorStamp],[Status],[FailureDate],[CreateDateTimeStamp]) VALUES ('an001','testrecord','1048-00', 'mccja01', 'Open',' # dtFailure # ', Now() );"
I will keep working to see how to get it to accept this variable as a date. Always another problem/opportunity opening.
I have declared all my variables but not included all the preliminary code.
For anyone that is interested I changed the insert into statement to read
strSQL = "INSERT INTO tblNCProduct ([TrackingNumber],[LotNumber],[PartNo],[AccessCreatorStamp],[Status],[FailureDate],[CreateDateTimeStamp]) VALUES ('" & strInput & "','" & strLotNumber & "','" & strPartNumber & "', '" & strUser & "', '" & strStatus & "','" & dtFailure & "', Now() );"
and now it works.
Glad you got it. I was sure you didn't need the quotes or the #'s around the variable, but I was testing it first. I came back and you had figured it out. Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.