|
下面这段代码在原有MDB数据库中正常运行,可当我把数据表导到SQL中后却无法正常运行,这到底是为什么?是不是升迁数据后好多对象都不能用了?恳求各位高手解答,谢谢!
Set CostCode = db.OpenRecordset("SELECT [Account Code_BSF].[Account Code], [Account Code_BSF].T1, [Account Code_BSF].T6 FROM [Account Code_BSF] where [WBS Code]= " & str1)
With CostCode
Dim descrip As String
descrip = DLookup("[subject]", "[inv reg entry]", "[invoice reg no]=" & [Invoice Reg No] & " ")
Dim SuppCode As String
SuppCode = DLookup("[supplier code]", "[inv reg entry]", "[invoice reg no]=" & [Invoice Reg No] & " ")
Dim mAccountCode, mT1, mT6
maccoundcode = ![Account Code]
mT1 = ![T1]
mT6 = ![T6]
Set CostSplit = db.OpenRecordset("select * from [invoice_cost element] where [Invoice reg no2:]=" & [Invoice Reg No] & " and [Account Code]='" & ![Account Code] & "' and [T1]='" & ![T1] & "' and [T6]='" & ![T6] & "'")
With CostSplit
If CostSplit.RecordCount = 0 Then
CostSplit.AddNew
Else
CostSplit.Edit
End If
![Invoice Reg No2:] = [Invoice Reg No]
![Amount splited] = SplitAmount
![Account Code] = maccoundcode
![T1] = mT1
![T6] = mT6
![Description] = descrip
If Len(SuppCode) > 4 Then
![T4] = SuppCode
Else: ![T5] = SuppCode
End If
CostSplit.Update
End With
CostSplit.Close
End With
CostCode.Close |
|