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

opening and closing recordsets

Status
Not open for further replies.

autoIT

IS-IT--Management
Joined
May 10, 2006
Messages
68
Location
US
I am attempting to open a recorset gather info into variables, close that recordset open another recordset and put the info from the variables into that recordset. Here is a skeleton outline of my code:


rs.open "employees",,,,,,,,(there are arguments here)
rs.close
rs.open"Query Employees",,,,,(again arguments)

it allows me to close and ope once, but when i goto close again i get an error that says arguments do not work in this context.


what am i doing wrong?


adam
 
If I follow you correctly, you have a recordset "employees" you open the get variables. You then open a DIFFERENT recordset "Query Employees".

Why not use two variables?

Code:
rs1.open "employees",,,,,,,,(there are arguments here)
rs1.close
rs2.open"Query Employees",,,,,(again arguments)

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Why not use an update statement on the second table something like.

Update table2 set field1 = (select whatever from table 1 where criteria here) where criteria here.



Andy Baldwin

"Testing is the most overlooked programming language on the books!"

Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.
 
Why do you want to close the recordset if you plan on using it again. Once you close it will be necessary to allocate a new instance. Instead just open the 2nd query to produce the new recordset. If you want 2 recordsets open at the same time then you will need to create the 2nd recordset like mstrmage1768 shows.
 
autoIT . . .

Be more specific about what you want to do! . . . As it is your current scheme is full of diviation in reading!

. . . [blue]Perhaps a discrete/explicit example![/blue] . . .

Calvin.gif
See Ya! . . . . . .
 
If you are trying to copy data from one table to another, why not just open two recordsets at the same time, the first as your source and the second being the one to modify?

But if you are going to recycle a recordset object, you should "new" it before using it again.
Code:
rs.open "employees",,,,,,,,(there are arguments here)
rs.close
[COLOR=red]Set rs = New ADODB.Recordset[/color]
rs.open"Query Employees",,,,,(again arguments)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top