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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get a date from an input box

Status
Not open for further replies.

JaneInMA

Programmer
Nov 3, 2000
104
US
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top