By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,799 Members | 1,327 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,799 IT Pros & Developers. It's quick & easy.

Copy field with DoCmd

P: n/a

Copy the content of a field into another field

In my table Customers i want to copy the content of the field
"Employee"
which is a text field, into the field MOL, also a text field
I need to copy the field through code, with DoCmd.statement
Can somebody help me ?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Doesn't make a lot of sense to me to store the same value in two fields in
the same record, but you can do it through code or a query. This code will
set "MOL" to the value of "Employee" in every record:

Dim db as DAO.Database
Dim rs as DAO.Recordset
Set db = CurrentDB
Set rs = db.OpenRecordset("Customers")
If Not(rs.EOF and rs.BOF) Then 'rs is not empty
rs.MoveFirst
Do Until rs.EOF = True
rs.Edit
rs("MOL") = rs("Employee")
rs.Update
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
Set db = Nothing

Or you can use a Query... here's the SQL... you can execute it manually, or
from code with the .Execute method:

UPDATE Customers SET Customers.MOL = [Customers].[Employee];

If you want to do this only for specific records, obviously then you'll have
to select just the records you want to update, but you didn't mention that.

Larry Linson
Microsoft Access MVP
"Svelte Poshy" <sv******@yahoo.com> wrote in message
news:3f*********************@news.frii.net...

Copy the content of a field into another field

In my table Customers i want to copy the content of the field
"Employee"
which is a text field, into the field MOL, also a text field
I need to copy the field through code, with DoCmd.statement
Can somebody help me ?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.