saving a recordset to a table? (1 Viewer)

Darth Vodka

Registered User.
Local time
Today, 17:28
Joined
Sep 25, 2007
Messages
344
hi

have trawled the posts and seen that you can save a recordset to xml then import it, but can you just save a recordset to a table withough the xml step?

thanx in advance
 

jubb

Registered User.
Local time
Tomorrow, 02:28
Joined
Jul 27, 2005
Messages
50
assuming you want to append to recordset to an existing table:


in example rs1 would be your existing recordset.

Code:
dim rs2 as dao.recordset

set rs2 = currentdb.openrecordset("tbl_Name") 'name of table you want to append records to

rs1.movefirst
while not rs1.eof
    rs2.addnew
    rs2!FieldName = rs1!FieldName 'etc etc for however many fields in recordset
    rs2.update
    rs1.movenext
wend
rs1.close
rs2.close
set rs1 = nothing
set rs2 = nothing

Hope that helps, probably a better way to do it but the above works for me.
 

Dennisk

AWF VIP
Local time
Today, 17:28
Joined
Jul 22, 2004
Messages
1,649
use an append query
 

Darth Vodka

Registered User.
Local time
Today, 17:28
Joined
Sep 25, 2007
Messages
344
jubb: thanx, i was thinking i could do it by toggling through them, but like you i was suspicious there might be a niftier way

Dennisk: an append query is assuming that my recordset is a SQL based one, what i'm actually thinking about doing is using the:-

CurrentProject.Connection.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

recordset and dumping that into a table

i can toggle throught it, just wondered if i was missing a one line trick to move a recordset to a table
 

jubb

Registered User.
Local time
Tomorrow, 02:28
Joined
Jul 27, 2005
Messages
50
Pretty sure you will have to toggle through them with what you are doing.

Just out of interest are you trying to get a list of current users accessing the DB?
 

Users who are viewing this thread

Top Bottom