i am writing a macro to convert the zeros in the access table to "0000"
Zero is text data type so i cast it to int in the if condition to update the records which is only zeros and preventing it in updating records which are non zeros
but now all the records are getting updated ..if clause is calling all the time even there is a value 2 in the particular row
please help
Dim db As Database
Dim rst As Recordset
Dim strData As String
Set db = CurrentDb()
Dim qryString As String
qryString = "SELECT * FROM tblECodes "
Set rst = db.OpenRecordset(qryString)
rst.MoveFirst
Do While Not rst.EOF
Dim testid As String
Dim Sch1 As Integer
Sch1 = CInt(rst.Fields("Scheduled"))
Testid1 = rst.Fields("Testid")
If Sch1 = "1" Then
strSQLUp = "Update tblECodes set scheduled = '0000' where testid = 148"
CurrentDb.Execute strSQLUp
End If
rst.MoveNext
Loop
rst.Close
db.Close