can we set a primary key on a form in access database if yes how?

  • Thread starter Thread starter Pd
  • Start date Start date
P

Pd

Hi , Can someone tell me if there is a way to set primary key in form view
for access database, if yes how?
 
Pd said:
Hi , Can someone tell me if there is a way to set primary key in form view
for access database, if yes how?

I don't think you can accomplish that goal, you might want to explain a
little bit where you are going with this.

If your primary key on your form is displayed as a field, and also it is not
an auto number, then you can simply enter the value into the form, and yu be
"setting" the value of the primary key.

However I think you are talking about setting a single field (collum) in the
table and defining it as the primary key. In this case, then no, you cannot
do that from the form's design mode.

You have to simply open a table in design mode and define a new field that's
going to be the primary key, or you can in fact select one of the existing
fields and have that become your primary key.
 
Hi , Can someone tell me if there is a way to set primary key in form view
for access database, if yes how?

No. A Form doesn't contain any data and a Form doesn't have a primary key (or
any sort of key). A Form is just a window, a tool to look at and edit data
stored in a Table.

You can set a Primary Key on a field (or on up to ten fields if desired) in a
Table, and then display that Table using a form, though.
 
Can someone tell me if there is a way to set primary key in form
view for access database, if yes how?

I'm not sure what you're question means, to be honest.

If you want a form to type in the value that will become the primary
key, you have to consider what you do when the user types in a value
that's already in use as a primary key.

My approach to this is to use a separate unbound form to collect the
data for the fields required to create a new record, and then check
to see if the resulting primary key already exists. If it does, you
tell the user and offer them some way around it. Once they've
entered data that won't create a collision, then you create the
record in DAO, and then load the new record in the main form for
them to fill out the other fields.

I have found this approach to be much more manageable than trying to
do the add in the same form as you do the edits.
 
Back
Top