Looping until end.

R

radink

I have a form and Would like to copy and paste from one field to another. Ihave the vba code tied to a button and it works. I would like to now loop it to do all of the records in the database. I tried a few ideas, but it runs forever creating tons of new records. Im not sure what code I should usein the loop to stop it.

Here's my code so far:

Do
Me!Text199.SetFocus
DoCmd.RunCommand acCmdCopy

Me!gt1.SetFocus
DoCmd.RunCommand acCmdPaste

DoCmd.GoToRecord , , acNext
Loop
 
R

radink

I fixed it.


Dim rst As Recordset
Set rst = Recordset

While Not rst.EOF And Not rst.BOF
Me!Text199.SetFocus
DoCmd.RunCommand acCmdCopy

Me!gt1.SetFocus
DoCmd.RunCommand acCmdPaste

rst.MoveNext
Wend
 
J

John W. Vinson

I have a form and Would like to copy and paste from one field to another. I have the vba code tied to a button and it works. I would like to now loop it to do all of the records in the database. I tried a few ideas, but it runs forever creating tons of new records. Im not sure what code I should use in the loop to stop it.

Here's my code so far:

Do
Me!Text199.SetFocus
DoCmd.RunCommand acCmdCopy

Me!gt1.SetFocus
DoCmd.RunCommand acCmdPaste

DoCmd.GoToRecord , , acNext
Loop

First off, data is stored in Tables, not in Forms; secondly, and as a result,
an Update query (to copy data from one field to another in the same record) or
and Append query (to create new records) is going to be much, much simpler
than any sort of copy-paste action.

I have to ask - what's the point in storing the same data redundantly at all?
Could you describe your current table structure, and what you want to
accomplish (in terms of table records and fields) - and why?
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 

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

Top