View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rowan Drummond[_3_] Rowan Drummond[_3_] is offline
external usenet poster
 
Posts: 414
Default Excel VBA - Copying access column

Hi

One way would be to use automation. This code copies all records from
the field Data1 to the field Data2 in my table, Table1. Test this on a
copy of your database as you will overwrite any data in the target field
(Data2 in my example).

You will have to set a reference to the Microsoft Access Object Library
if you haven't already done so.

Sub updrecords()
Dim accessApp As New Access.Application
Dim sql As String
sql = "UPDATE Table1 " & _
"SET Table1.Data2 = Table1.Data1"
With accessApp
.OpenCurrentDatabase ("C:\Temp\TempDB.mdb")
.DoCmd.RunSQL sql
End With
accessApp.Quit
Set accessApp = Nothing
End Sub

Hope this helps
Rowan

wliong wrote:
Hi,

I want to copy from one column to another column in access table using
excel VBA. Is there any way that I can do that?

Thanks very much