Link to home
Start Free TrialLog in
Avatar of QLJ
QLJFlag for Afghanistan

asked on

How do I insert the current date into Access?

Hi,
 I have this form online and I want to be able to write the date and time of submission into this access database that I have. How do i do it?
In my database, the field should be of type date/time or what?

Thanx
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Make Now() the default for that column.
Avatar of QLJ

ASKER

sqlStr = "Insert into Feedback(FirstName,LastName,Designation,CompanyName,Position,Email,Contact,Feedback,SysDate,SysTime) & Values ('" & request("firstname") & "', '" & request("lastname") & "', '" & request("radiobutton") & "', '" & request("company") & "', '" & request("position") & "','" & request("email") & "','" & request("number") & "','" & request("feedback") & "')"

say I want to enter the date and time into the db(SysDate, SysTime), what should I do?

the now()works fine if I just want to display, but when I try to insert, nothing is inserted. I was wondering what might have gone wrong...
Try this:

sqlStr = "Insert into Feedback(FirstName,LastName,Designation,CompanyName,Position,Email,Contact,Feedback,SysDate,SysTime) & Values ('" & request("firstname") & "', '" & request("lastname") & "', '" & request("radiobutton") & "', '" & request("company") & "', '" & request("position") & "','" & request("email") & "','" & request("number") & "','" & request("feedback") & ", Date(), Time()')"
>>In my database, the field should be of type date/time or what?
Yes, exactly.
Avatar of QLJ

ASKER

hmm.. this doesnt solve the problem. The SysDate and SysTime field remains empty in the database
SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of QLJ

ASKER

oh no.. your first method doesnt work

>>Go to the Table Design Window, select the Feedback table, select the file SysDate, set it's Default Property to =Date(), >>and then select the SysTime field, set it's Default Property to =Time()

Which field do you mean? in the Format field of the Field Properties?

ps. Thanx for the effort! (even though it is of measly points) Decided to up it to make it up to you!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Now more clear, QLJ ?
Avatar of QLJ

ASKER

hey.. thanx guys! it worked! I'm a happy person! :)
sorry acperkins, din really get what you meant initially. :)