Conditional Default Value,

G

Guest

Can you have the default value, be conditional to another field in the table?

Example I want the default value m-f to be different than the weekend. Is
there a way of acheiving this?

Another question is there a way of creating a key from other fields in the
table, for instance, name, date time are other fields, I want the primary key
to be all 3 together therefore they will not be duplicated? I tried doing
this with a form and a macro to update the form, but for some reason it
didn't update and then I couldn't go on because of the primary field being
empty.
 
G

Guest

You can define DefaultValue as a formula or a specific value in a control
(Just put an = before). For example, for combo boxes I have the first value
as default:

combo1.DefaultValue =[Combo1].[ItemData](0)

Primary Key multi-field----
- Open the design mode for your table
- Put all field for the PK on the top
- Select all of them
- Press the button for Primary Key (the key button)

Take Care

Mauricio Silva
 
G

Guest

Thank you so much. I have been using access for years and never knew you
could have more than 1 primary in a table. This will help so much. I think I
understand the other. Thanks again.

Mauricio Silva said:
You can define DefaultValue as a formula or a specific value in a control
(Just put an = before). For example, for combo boxes I have the first value
as default:

combo1.DefaultValue =[Combo1].[ItemData](0)

Primary Key multi-field----
- Open the design mode for your table
- Put all field for the PK on the top
- Select all of them
- Press the button for Primary Key (the key button)

Take Care

Mauricio Silva

Jody said:
Can you have the default value, be conditional to another field in the table?

Example I want the default value m-f to be different than the weekend. Is
there a way of acheiving this?

Another question is there a way of creating a key from other fields in the
table, for instance, name, date time are other fields, I want the primary key
to be all 3 together therefore they will not be duplicated? I tried doing
this with a form and a macro to update the form, but for some reason it
didn't update and then I couldn't go on because of the primary field being
empty.
 
T

Tom Wickerath

Jody,

You cannot have more than one primary key in a table. Although a key icon will be displayed in
each field in table design view, they are all part of a single combined field primary key. They
are not separate primary keys. Before you go too far with such a design, you might want to read
the following articles:

Why to avoid composite Primary Keys
http://www.utteraccess.com/forums/s...=247916&page=0&view=collapsed&sb=5&o=&fpart=1

and "The Case for the Surrogate Key"
available at: http://www.access.qbuilt.com/html/articles.html


Regarding your first question:
Can you have the default value, be conditional to another field in the table?

Yes, you can. How comfortable are you with VBA code?

Tom
_________________________________


Thank you so much. I have been using access for years and never knew you
could have more than 1 primary in a table. This will help so much. I think I
understand the other. Thanks again.
_________________________________


You can define DefaultValue as a formula or a specific value in a control
(Just put an = before). For example, for combo boxes I have the first value
as default:

combo1.DefaultValue =[Combo1].[ItemData](0)

Primary Key multi-field----
- Open the design mode for your table
- Put all field for the PK on the top
- Select all of them
- Press the button for Primary Key (the key button)

Take Care

Mauricio Silva

_________________________________


Can you have the default value, be conditional to another field in the table?

Example I want the default value m-f to be different than the weekend. Is
there a way of achieving this?

Another question is there a way of creating a key from other fields in the
table, for instance, name, date time are other fields, I want the primary key
to be all 3 together therefore they will not be duplicated? I tried doing
this with a form and a macro to update the form, but for some reason it
didn't update and then I couldn't go on because of the primary field being
empty.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top