entering multiple records with a single form

S

sheela

I am creating a freezers database for my lab, which will
store the information of samples stored in the freezer.
Many times a sample will be divided into multiple tubes
and will be saved in multiple positions in the freezer. In
that case all the fields for that sample will be same
except the field "position" whose data type is a number.
I want to create a form where the user enters the start
and end positions say (1 and 10) and all the remaining
fields' information. Then the information would be stored
in 10 records from position 1 through 10 and the rest of
the fields have the same information in those 10 records.
It has an auto number as a primary key, it will be unique
for each entry.
Could some one tell me how to program this in the forms?
I have created a form; with that one the user can enter
one record at a time. This is working fine.
But I am having difficulty in creating another form for
multiple record entries with the above criteria.

Any help would be greatly appreciated.

Sheela.
 
M

Marshall Barton

sheela said:
I am creating a freezers database for my lab, which will
store the information of samples stored in the freezer.
Many times a sample will be divided into multiple tubes
and will be saved in multiple positions in the freezer. In
that case all the fields for that sample will be same
except the field "position" whose data type is a number.
I want to create a form where the user enters the start
and end positions say (1 and 10) and all the remaining
fields' information. Then the information would be stored
in 10 records from position 1 through 10 and the rest of
the fields have the same information in those 10 records.
It has an auto number as a primary key, it will be unique
for each entry.
Could some one tell me how to program this in the forms?
I have created a form; with that one the user can enter
one record at a time. This is working fine.
But I am having difficulty in creating another form for
multiple record entries with the above criteria.


I hope you have the "position" field in the table marked as
a UNIQUE index.

You can enter records in the table several ways. One is to
use code to construct an Insert Into query with the values
and then repeatedly Execute the query.

Another way is to use the Form's RecordsetClone with AddNew.
I think this way is a little more straightforward:

With Me.RecordsetClone
For K = Me.txtStartPos To Me.txtEndPos
.AddNew
!Position = K
!field1 = Me!field1
!field2 = Me!field2
. . .
.Update
Next K
End With

And don't skimp on the error handling, you might make a mess
of things if someone makes a mistake with the start and end
values.

If the form is a bound form, you'll have to adjust things so
you don't try to enter the data on the form an extra time.
 

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