PC Review


Reply
Thread Tools Rate Thread

Current date in a table field

 
 
=?Utf-8?B?bXNhbmV3YmVl?=
Guest
Posts: n/a
 
      22nd Jun 2006
Is there a way to have the current date automatically put in a table field
whenever a new record is created?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?eFJvYWNoeA==?=
Guest
Posts: n/a
 
      22nd Jun 2006
Hi -- In design view, add the following to the default value for the date
field:
Date()



"msanewbee" wrote:

> Is there a way to have the current date automatically put in a table field
> whenever a new record is created?

 
Reply With Quote
 
=?Utf-8?B?bXNhbmV3YmVl?=
Guest
Posts: n/a
 
      22nd Jun 2006
That works perfect. Thanks!!

"xRoachx" wrote:

> Hi -- In design view, add the following to the default value for the date
> field:
> Date()
>
>
>
> "msanewbee" wrote:
>
> > Is there a way to have the current date automatically put in a table field
> > whenever a new record is created?

 
Reply With Quote
 
Jamie Collins
Guest
Posts: n/a
 
      23rd Jun 2006

msanewbee wrote:
> Is there a way to have the current date automatically put in a table field
> whenever a new record is created?


Use either NOW() or DATE() as the column's default value e.g.

Sub effective_date()
Kill "C:\DropMe.mdb"
Dim cat
Set cat = CreateObject("ADOX.Catalog")
With cat
.Create _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\DropMe.mdb"
With .ActiveConnection

' Create test table
.Execute _
"CREATE TABLE Test4 (key_col INTEGER NOT" & _
" NULL UNIQUE, effective_date DATETIME DEFAULT" & _
" NOW() NOT NULL); "

' Create test row (default gets applied)
.Execute _
"INSERT INTO Test4 (key_col) VALUES (1);"

' Show results
Dim rs
Set rs = .Execute( _
"SELECT key_col, effective_date" & _
" FROM Test4;")
MsgBox rs.GetString
rs.Close
End With
Set .ActiveConnection = Nothing
End With
End Sub

Jamie.

--

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bound Date/Time field to automatically display the current date Billiam Microsoft Access Database Table Design 2 20th Sep 2009 11:13 PM
Inser the current date into a field in a Table jeanhurtado@gmail.com Microsoft Access 2 28th Mar 2007 05:34 PM
HOW TO SET A DATE FIELD WITH CURRENT DATE TO SHOW A WARNING MESSA. =?Utf-8?B?ZGVlcHU=?= Microsoft Access 1 15th Mar 2005 08:22 AM
Date created field (auto current date fill-in) Lauri Microsoft Access Forms 3 13th Jul 2004 08:43 PM
Update Date field to current date after duping the record Earl Dillon Microsoft Access Form Coding 1 7th Aug 2003 07:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:47 AM.