If rptReduct1.State = adStateOpen Then rptReduct1.Close
rptReduct1.Open "select id from employee", dbConnect, adOpenDynamicFor intI = 0 To rptReduct1.RecordCount - 1
rptReduct1.Fields("reduct").Value = 0
rptReduct1.MoveNext
Next intI
当执行的时候,总是跳过FOR循环,调试的时候说我的总说我的rptReduct1.RecordCount的值为-1,而我的数据库id字段确实有20个值,不知道这是为什么清各位帮忙解答!100分相送!
rptReduct1.Open "select id from employee", dbConnect, adOpenDynamicFor intI = 0 To rptReduct1.RecordCount - 1
rptReduct1.Fields("reduct").Value = 0
rptReduct1.MoveNext
Next intI
当执行的时候,总是跳过FOR循环,调试的时候说我的总说我的rptReduct1.RecordCount的值为-1,而我的数据库id字段确实有20个值,不知道这是为什么清各位帮忙解答!100分相送!
rptReduct1.Open "select id from employee", dbConnect, adOpenDynamic, adlockoptimisticFor intI = 0 To rptReduct1.RecordCount - 1
rptReduct1.Fields("reduct") = 0
rptReduct1.MoveNext
Next intI
If rptReduct1.State = adStateOpen Then rptReduct1.Close
rptReduct1.Open "select id, reduct from employee", dbConnect, adOpenDynamic, adlockoptimistic
rptReduct1.movefirst
rptReduct1.movelastFor intI = 1 To rptReduct1.RecordCount
rptReduct1.Fields("reduct") = 0 '你要更新reduct字段,查询中必须有这个字段
rptReduct1.MoveNext
Next intI
如果还有问题,请在ACCESS表中查看你的ID字段是否有问题,或直接在ACCESS中用这个SQL语句查出结果来看看
rptReduct1.CursorLocation = adUseClient
rptReduct1.Open "select id from employee", dbConnect, adOpenDynamicFor intI = 0 To rptReduct1.RecordCount - 1
rptReduct1.Fields("reduct").Value = 0
rptReduct1.MoveNext
Next intI
rptReduct1.Open "select id from employee", dbConnect, adOpenStatic, adlockoptimisticFor intI = 0 To rptReduct1.RecordCount - 1
rptReduct1.Fields("reduct") = 0
rptReduct1.MoveNext
Next intI
rptReduct1.Open "select id from employee", dbConnect, adOpenDynamic,adLockOptimistic