Depends on how you would like to do it.
The easiest is to create a Data enviroment connect it to the Database set acommand to he table and then
Private Sub Command1_Click()
DataEnvironment1.rsCommand1.Open
With DataEnvironment1.rsCommand1
Do Until DataEnvironment1.rsCommand1.EOF
if not isnull(!SSN) then
!SSN2 = !SSN
.Update
.MoveNext
Loop
End With
DataEnvironment1.rsCommand1.Close
MsgBox "Update complete"
End Sub
The second is to do it through ADO
Dim aMainrecord As New ADODB.Recordset
Dim strSql As String
Dim aMainrecConn As New ADODB.Connection
strSql = "Select * from TABLENAME"
aMainrecConn.Open "Provider=SQLOLEDB; Data Source=SERVERNAME; " & "Initial Catalog=DATABASENAME; User Id=**; Password=**"
aMainrecord.CursorLocation = adUseClient
aMainrecord.Open strSql, aMainrecConn, adOpenStatic, adLockUnspecified
While Not aMainrecord.EOF
If Not IsNull(aMainrecord("SSN") Then
aMainrecord("SSN2" = aMainrecord("SSN"
aMainrecord.Update
aMainrecord.MoveNext
Wend
aMainrecConn.Close
Set aMainrecConn = Nothing
Set aMainrecord = Nothing
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.