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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to cycle through a table and reset field values to 0 or blank

Status
Not open for further replies.

svenman

Technical User
Jun 19, 2006
11
US
I have a command button that when pressed I want to update certain values in the table to 0 or blank I need to do this for each record in the table.

I know VFP not vb

if VFP it would be
DO while !eof()
replace .....
skip
enddo

This is what I have so far but I do not know the code to update the table values this is my code so far
result = MsgBox("Warning Command will reset all values to 0 or Blank, Continue", vbYesNo, "Answer Requested")
If result = vbYes Then
Dim strNewRecord As String
strNewRecord = "SELECT * FROM IT "
Me.RecordSource = strNewRecord


Else
End If

Thanks Terry
 
It is often easier to run an update query. You can do it through VBA. That being said:

Code:
Dim rs As DAO.Recordset
'Needs reference to Microsoft DAO 3.6 Object Library

Set rs=CurrentDB.OpenRecordset ("SELECT * FROM IT ")

Do While Not rs.EOF
   rs.Edit
   rs!ThisField = 0
   rs.Update
   rs.MoveNext
Loop

An update query:

Code:
strSQL="Update IT Set ThisField=0"
CurrentDB.Execute strSQL, dbFailOnError
 
Thanks Remou I'll give it a try it should work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top