Using code to add records through a form. 
Author Message
 Using code to add records through a form.

I have a table in my database that contains several fields of statistics for
each unique client.  I also bring data in regularly, through the use of
code.  Occasionally there are new clients in the data being brought in.  To
maintain referential integrity, I have code that checks to see that each
client being brought in has an entry in the original table.  When I find
clients that do no thave an entry, I want to open a form to add them to the
original table.  The data being brought in does not have all of the
statistics necessary to fill in the original table (which uses a primary key
that is initially calculated based on multiple fields of each record).  I
have been able to use a couple of different methods to open the form and
automatically fill in the data from the import'.  My problem is that I have
not been able to add the rest of the necessary information to each record.
The form currently has the original table as a record source.  Keeping the
record source in tact, I have been able to use OpenForm...acAdd which adds
the records and continues execution without allowing me to add the rest of
the data.  Another method that produces about the same result is opening as
normal and adding new record.  Through another suggestion I tried to change
the record source to be a query, but i could not modify each record
individually using this method.

I would appreciate any ideas anyone has (either modification to methods
already tried or new suggestions).  Thanks.



Thu, 28 Dec 2000 03:00:00 GMT  
 Using code to add records through a form.
Try something like this:

dim r as recordset
set r = me.recordsetclone
do
   r.addnew
        r!FieldThis = "This"
        r!FieldThat = "That"
        ...
   r.update
loop until Done
That should help.

Quote:

> I have a table in my database that contains several fields of statistics for
> each unique client.  I also bring data in regularly, through the use of
> code.  Occasionally there are new clients in the data being brought in.  To
> maintain referential integrity, I have code that checks to see that each
> client being brought in has an entry in the original table.  When I find
> clients that do no thave an entry, I want to open a form to add them to the
> original table.  The data being brought in does not have all of the
> statistics necessary to fill in the original table (which uses a primary key
> that is initially calculated based on multiple fields of each record).  I
> have been able to use a couple of different methods to open the form and
> automatically fill in the data from the import'.  My problem is that I have
> not been able to add the rest of the necessary information to each record.
> The form currently has the original table as a record source.  Keeping the
> record source in tact, I have been able to use OpenForm...acAdd which adds
> the records and continues execution without allowing me to add the rest of
> the data.  Another method that produces about the same result is opening as
> normal and adding new record.  Through another suggestion I tried to change
> the record source to be a query, but i could not modify each record
> individually using this method.

> I would appreciate any ideas anyone has (either modification to methods
> already tried or new suggestions).  Thanks.



Thu, 28 Dec 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. More on Using code to add records through a form.

2. Create custom control in form using code (code wizard adding ocx to form)

3. Can't add new records when using Linked forms

4. Using Access VBA to add multiple records in a loop to a table from a form

5. Please comment on my ugly code- for retrieving record on a form using a combo box

6. ADO2.5, can't add new record to an empty table using record binding

7. Problems Adding Records from a Form containing a Sub-form

8. requery parent form when user adds a record to child form

9. How to add code to form and controls from my Add-In

10. Specify what procedure to add code to using Add-in

11. Adding code using Add In

12. how to add picture into table using ado code not using control

 

 
Powered by phpBB® Forum Software