Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

append records to a table 1

Status
Not open for further replies.

Ju

Technical User
Jul 4, 2000
61
FR
I have a form which allow me to enter records in a table.<br>I'd like these records to be added to a table, adding it small parts by small parts (appending it), so that I can have an image of all the records I have created. <br>Indeed, I erase my records when I am done creating an output file, so I have no copy of what I exported.<br><br>Thank you.
 
You can do this in the code of the form<br><br>&nbsp;&nbsp;&nbsp;dim db as database, recset as recordset<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;set db = dbengine.workspaces(0).databases(0)<br>&nbsp;&nbsp;&nbsp;set recset =&nbsp;&nbsp;db.openrecordset(&quot;table name&quot;, db_open_dynaset)<br><br>if you want to add a new record you use<br><br>&nbsp;&nbsp;&nbsp;recset.addnew<br>&nbsp;&nbsp;&nbsp;recset![fieldname] = value<br>&nbsp;&nbsp;&nbsp;...<br>&nbsp;&nbsp;&nbsp;recset.update<br><br>if you want to edit an existing record you would use<br><br>&nbsp;&nbsp;&nbsp;recset.edit<br>&nbsp;&nbsp;&nbsp;recset![field name] = value<br>&nbsp;&nbsp;&nbsp;...<br>&nbsp;&nbsp;&nbsp;recset.update<br><br>that should work for you if you have more questions post them. <br> <p>Walt III<br><a href=mailto:SAElukewl@netscape.net>SAElukewl@netscape.net</a><br><a href=
 
I have to admit that here I'm pretty lost...<br>I think i need the exact procedure one time to understand...<br>Sorry.
 
You say that you &quot;erase my records when I am done creating an output file&quot;.&nbsp;&nbsp;Do you do that so that you can enter new records at a later date and create a new output file?<br><br>If so, you could append the data in the entry table to another table, call it the archive table, before erasing.<br><br>Does that sound like it would work?&nbsp;&nbsp;If so, post the method you are using to create the output file and give us the name of the tables and forms you are using.<br><br>Kathryn
 
It's exactly what I do.<br><br>I use the macro TransferText to output to a text file.<br>I am using 3 tables but want to save the content of only one: &quot;detail&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the other are &quot;tete&quot; an &quot;queue&quot;.<br>my forms are &quot;enregistre la queue&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;enregistre le detail&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;enregistre la tete&quot;<br>that's it.<br>Thanks a lot.
 
OK, you need to create a table.&nbsp;&nbsp;It should have the exact same structure (field names, sizes, everything) as detail.&nbsp;&nbsp;The easiest way to do this is to copy &quot;detail&quot; and paste only the structure.&nbsp;&nbsp;You can do this in the database window.&nbsp;&nbsp;RightClick on detail, choose Copy and the right click again and choose Paste.&nbsp;&nbsp;Choose Structure only, call it tblDetailArchive.<br><br>Create a new query, call it qryDetailArchiveAppend. Add the table detail to the query.&nbsp;&nbsp;Change the query type to append.&nbsp;&nbsp;You want to append to tblDetailArchive, so enter that when asked.&nbsp;&nbsp;Then doubleclick on the asterisk in the fieldlisting for detail.&nbsp;&nbsp;This will cause all fields to be appended.<br><br>Make sure you save the query.<br><br>In your code, after the TransferText command, run the query by entering this line<br><br>CurrentDb.QueryDefs(&quot;qryDetailArchiveAppend&quot;).Execute<br><br>This will append the records.&nbsp;&nbsp;If you are using macros, you can just use RunQuery or whatever the command is.<br><br>Kathryn<br>
 
Thank you a lot Kathryn, it couldn't be better explained (to a french even tho...)<br><br>It seems to be working with no problems at all.<br><br>Thank you very much again.<br>Ju.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top