Solved

How do I insert the current date into Access?

Posted on 2004-04-11
10
664 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:QLJ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
10 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 10803425
Make Now() the default for that column.
0
 
LVL 1

Author Comment

by:QLJ
ID: 10803917
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...
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 10804389
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()')"
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 52

Expert Comment

by:Ryan Chong
ID: 10804391
>>In my database, the field should be of type date/time or what?
Yes, exactly.
0
 
LVL 1

Author Comment

by:QLJ
ID: 10810015
hmm.. this doesnt solve the problem. The SysDate and SysTime field remains empty in the database
0
 
LVL 52

Assisted Solution

by:Ryan Chong
Ryan Chong earned 90 total points
ID: 10810973
Opps! Typo.. try this again?

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())"


if still doesnt work (shouldnt be), try as what acperkins already suggested:

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()

then change your statement to:

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

Hope this works
0
 
LVL 1

Author Comment

by:QLJ
ID: 10811313
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!
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 110 total points
ID: 10812720
>>Which field do you mean? in the Format field of the Field Properties?<<
No, not the Format, but (as I suggested previously) the Default Value.
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 10819704
Now more clear, QLJ ?
0
 
LVL 1

Author Comment

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

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

742 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question