Current date as default

  • Thread starter norwedsh via AccessMonster.com
  • Start date
N

norwedsh via AccessMonster.com

Hi,
I would like to be able to have the date set by default, as the
current date, when the table is created. I'm kinda new to SQL and am taking a
course in it. Here is my current SQL code:

create table
tblOrder
(
Order_ID counter,
Cus_ID integer,
Sale_Date Date,
Sale_Quantity integer,
Price currency,
Constraint Order_ID_PK primary key(order_id)
);

Sale_Date is the field in question, my instructor implied that the VB now()
function can be used, but I'm lost as how to use it.

Thanks in advance

Eric
 
N

norwedsh via AccessMonster.com

Um, Yes? He he. I want to make use of the default value property, I've been
having trouble with the syntax. The field sale_date should provide the
current date by default

thanks,

Eric

Jeff said:
Current date of what? "when the table is created"... implies the table. Do
you want the default date to be for a field within the table? You can do
that in the field's Default Value property.
Hi,
I would like to be able to have the date set by default, as the
[quoted text clipped - 18 lines]
 
J

Jeff Boyce

Please re-read my response. The field (both at the table level and in a
form) has a Default value property, which you can set to be the current
date.

If you only want the date, you would use =Date(). If you want date/time,
use =Now().

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


norwedsh via AccessMonster.com said:
Um, Yes? He he. I want to make use of the default value property, I've been
having trouble with the syntax. The field sale_date should provide the
current date by default

thanks,

Eric

Jeff said:
Current date of what? "when the table is created"... implies the table. Do
you want the default date to be for a field within the table? You can do
that in the field's Default Value property.
Hi,
I would like to be able to have the date set by default, as the
[quoted text clipped - 18 lines]
 
N

norwedsh via AccessMonster.com

Yeah I know. My instructor want us to do it with SQL code! I don't want the
date the table is created, what I want is when the table is created to have
the current date entered by default when data is added to other fields. You
saw my code right? If I understand correctly there is a way to define that
Sale_Date has Now() as a default.

Eric

Jeff said:
Please re-read my response. The field (both at the table level and in a
form) has a Default value property, which you can set to be the current
date.

If you only want the date, you would use =Date(). If you want date/time,
use =Now().
Um, Yes? He he. I want to make use of the default value property, I've been
having trouble with the syntax. The field sale_date should provide the
[quoted text clipped - 15 lines]
 
J

John Spencer

You can do that (set a default value) in MS SQL Server. I'm don't believe
you can do it ins Access.


norwedsh via AccessMonster.com said:
Yeah I know. My instructor want us to do it with SQL code! I don't want
the
date the table is created, what I want is when the table is created to
have
the current date entered by default when data is added to other fields.
You
saw my code right? If I understand correctly there is a way to define that
Sale_Date has Now() as a default.

Eric

Jeff said:
Please re-read my response. The field (both at the table level and in a
form) has a Default value property, which you can set to be the current
date.

If you only want the date, you would use =Date(). If you want date/time,
use =Now().
Um, Yes? He he. I want to make use of the default value property, I've
been
having trouble with the syntax. The field sale_date should provide the
[quoted text clipped - 15 lines]
 
Top