Just a query - Moving entry from 1 table to another

S

Steven Burn

I know I could probably write something along the lines of the below to do
this but, am hoping there's an easier way.

Basically what I am wanting to do is, select an entry in 1 table, then move
it to another. However, at the same time, in the second table, find all the
entries marked "Yes" in the "New" field, and change the oldest one to "No".

What I was thinking, was something along the lines of;

'// 1st table
rst.Open "Select * From tblMain Where ID = '" & strID & "'", DB,
adOpenStatic, adLockPessimistic
strTempID = rst("ID")
strTempField1 = rst("Field1")
'//..... all the way to the last field

'// 2nd table
rst.Open "Select * From tblNew", DB, adOpenStatic, adLockPessimistic
rst.AddNew
'// as the ID from the first table is most likely going to be taken
'// I'll just ignore strTempID, and add it as I would any other
rst("ID") = rst.RecordCount + 1
rst("New") = "Yes"
rst("Field1") = strTempField1
'//..... all the way to the last field
rst.Update

'// Locate the oldest entry that still has it's "New" field marked "Yes"
'// And change it's "New" field to "No"
rst.Open "Select * From tblNew", DB, adOpenStatic, adLockPessimistic
Do Until rst.EOF
If rst("New")="Yes" Then
'// This is where I'm now stuck.....
End If
rst.MoveNext
Loop

Apologies if this makes no sense, I've just woken up....... but this is
bugging the life out of me, so any advice would be appreciated.

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,129
Latest member
FastBurnketo
Top