|
本帖最后由 lms008008 于 2016-11-10 16:44 编辑
代码如下: 'update the tmpALRpt3_AftUpdData special field.
Sub frmAftUpdDatSpeFldVal(ByVal intTotAL As Integer, ByVal intNewAL As Integer)
Dim dbsDB As Database, rsAftUpdRecord As Recordset
Dim strNetCapAmt, strRevUnAmo, strCatUpAmt, strSql As String
Dim intMob, intRows, intTotRow As Integer
Set dbsDB = CurrentDb
1) Set rsAftUpdRecord = dbsDB.OpenRecordset("tmpALRpt3_AftUpdData", 1)
‘这时RecordCount的结果时正确的’
2):Set rsAftUpdRecord = dbsDB.OpenRecordset("select * from tmpALRpt3_AftUpdData")
'当时这种情况时,得到的RecordCount 结果变成1了,是错误的。
For intRows = 1 To rsAftUpdRecord.RecordCount
'begin to update the specail field
intMob = intRows
If intMob <= intNewAL Then
strNetCapAmt = rsAftUpdRecord.Fields("NetCapAmt")
strNetCapAmt = forSepFldVal(CDbl(strNetCapAmt), 2, "Normal")
'field2
strRevUnAmo = rsAftUpdRecord.Fields("RevUnAmoAmt")
strRevUnAmo = forSepFldVal(CDbl(strRevUnAmo), 2, "Normal")
strCatUpAmt = rsAftUpdRecord.Fields("catchUpAmt")
strCatUpAmt = forSepFldVal(CDbl(strCatUpAmt), 2, "CatUp")
strSql = "update tmpALRpt3_AftUpdData Set NetCapAmt='" & strNetCapAmt & "',RevUnAmoAmt ='" & strRevUnAmo & "', " & _
" catchUpAmt='" & strCatUpAmt & "' where RevMth=" & intMob & " "
Else
strNetCapAmt = rsAftUpdRecord.Fields("NetCapAmt")
strNetCapAmt = forSepFldVal(CDbl(strNetCapAmt), 2, "Normal")
strCatUpAmt = rsAftUpdRecord.Fields("catchUpAmt")
strCatUpAmt = forSepFldVal(CDbl(strCatUpAmt), 2, "CatUp")
strSql = "update tmpALRpt3_AftUpdData Set NetCapAmt='" & strNetCapAmt & "', " & _
" catchUpAmt='" & strCatUpAmt & "' where RevMth=" & intMob & " "
End If
CurrentDb.Execute (strSql)
rsAftUpdRecord.MoveNext
Next
Set rsAftUpdRecord = Nothing
Set dbsDB = Nothing
End Sub
请问大神:
1) Set rsAftUpdRecord = dbsDB.OpenRecordset("tmpALRpt3_AftUpdData", 1)
‘这时RecordCount的结果时正确的’
2):Set rsAftUpdRecord = dbsDB.OpenRecordset("select * from tmpALRpt3_AftUpdData")
'当时这种情况时,得到的RecordCount 结果变成1了,是错误的。
这两种用法有哪些区别呢? 用的是ACCESS 2007
|
|