How do I Insert the Date from a form to an Access Database

This one is easy I know.  But I have users inserting info in a form.  When they click submit I would like the form to also submit the date in which they submitted.  I know this has to be in a hidden field because I don't want them to see it.  I need to know what i need to do to do this.  Also, what kind of field does it have to be in the access database? ie. text, date?
LVL 2
ibtayaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
>>I know this has to be in a hidden field because I don't want them to see it.
Try grab the server date on ASP and insert the date to your Access database on ASP, like:

If you want include time as well, else try:

...
SQLStr = "Insert into mytable (field1, fieldN, insertDate) values ('" & field1 & "', " & fieldN & ", Now()) "
conn.execute SQLstr
...

else try:

...
SQLStr = "Insert into mytable (field1, fieldN, insertDate) values ('" & field1 & "', " & fieldN & ", Date()) "
conn.execute SQLstr
...

>>what kind of field does it have to be in the access database
Try Date/Time data type.
0
ibtayaAuthor Commented:
Where would this code go?  I'm kinda new at this.  Would it go in the value box for the hidden field?
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
>>Where would this code go?
In your form's submission process page, like if your form tag looks like below:

<form name="form1" method="post" action="process.asp" onSubmit="validate(this)">

The form's submission process page will be as "process.asp"

>>Would it go in the value box for the hidden field?
To store the date value into form's hidden field is a bad design/ idea. As you can't aspect when the user eventually do the submission, it can be 1 minute after, 1 hour after, even maybe... Furthermore anyone also can create a similar form, and put their data they want in the hidden field, and then do the submission. That's means it give a "Door" to those hacker that can intrude to your server.. So, try to avoid to put data on hidden field, while it can be done on backend process.

regards
0
Mark GilbertSenior Performance EngineerCommented:
Hi there,

if you are going to use a database, why not consider having a timestamp field on the table.  This will then enable the user to submit data using a form to the database, and the database will do all the work of calculating the exact date and time that the submission was created.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
triserosCommented:
I would go with inqwa's suggestion - set your DB field to date/time and in the default value field (at the bottom of teh design view) add the text,  Now() ,  this will create a date/timestamp for each new record added.

That way you don't need to use insert anything for the date/time as the DB will do it for you - just make sure to remove your hidden field from the form.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Dreamweaver

From novice to tech pro — start learning today.