Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy one field to another for multiple records 1

Status
Not open for further replies.

obulldog27

Programmer
Apr 26, 2004
169
US
I would like to press a button on a vb6.0 form that will
autmomatically copy one column of field and replace with a field in another column within the correspnding record. i want this to be done for multiple records in ms access.
This is what I have tried but it is not working.

Private Sub Command1_Click()
Adodc1.Recordset.MoveFirst
Do While Not Adodc1.Recordset.EOF
Adodc1.Recordset!beg_meter_reading = Val(endmetg.Text)
Adodc1.Recordset.Update
Adodc1.Refresh
Adodc1.Recordset.MoveNext
Loop
End Sub
 
If you could create a connection to the database and run an SQL update statement, then refresh your control, that might work?

Dim cnDB As New ADODB.Connection
cnDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & gsDatabase
cnDB.Open

sSQL="UPDATE TabelName SET beg_meter_reading = " & Val(endmetg.Text)
cnDB.Execute (sSQL)
cnDB.Close
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top