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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open recordset to new/empty temp table? 1

Status
Not open for further replies.

NXMold

Technical User
Jul 22, 2008
104
I am building a form to import and validate data from an xls form. I want to establish a recordset and begin looping to import data to a temporary table.

If I use rs.open with a SELECT '' AS Material INTO query I get a blank record.

How do I create the temp table with no records?
 
Why not just have a temp blank table to begin with, then

Set rsTempTable = Currentdb.OpenRecorset("Select * from TempTable")


rsTempTable.AddNew
'add record
rsTempTable.Update

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
But then the table will be full of records, the next time I run this I would have to delete all records? I guess that could work.
 
Or else you can write code to create a new table each time with all of the fields you want, fill it up with data, then delete it. Seems less painful to just create a table with the structure you want and just have it there waiting. Either way I think the db will bloat in a similar way; either creating and deleting a table each time, or adding and deleting records from a table each time, both things will bloat the db. Just compact regularly.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
I decided to use a persistant temp table and delete all records each time, its a pretty clean method.

Is there any way to combat bloat (seems prevalant with queries too) besides compact?
 
not in your case, where you are importing data over and over again. you can set the DB to "Compact On Close" (in the options) so that it compacts every time you close it.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top