以下是引用dfh93在2005-3-1 20:34:00的发言:
在Access中用VBA ,效果是否会好点?
当然啦!我对ADO和ODBC不太熟练,SQL比较容易理解(至少是现在)所以喜欢用SQL选出需要的数据后,复制到EXCEL里进行近一步的制表和细化。呵呵!半路出家的基础不扎实,不过能用就好,我现在处理分析7~8万条记录基本没有问题(机器不能太差)。
虽然太理解ADO,还是推荐一个在EXCEL中用SQL的例子,你自己琢磨一下。http://club.excelhome.net/viewthread.php?tid=71961
给一段我现在在ACCESS中用的代码,。
Sub 网点借方汇总()
'On Error Resume Next
A = InputBox("输入“200403”字样,并保证数据已经导入。借方")
DoCmd.RunSQL ("delete from 月网点借方汇总")
For X = 1 To 9 Step 1
Select Case X
Case 1
A = Left(A, 6) & "009"
Case 2
A = Left(A, 6) & "006"
Case 3
A = Left(A, 6) & "008"
Case 4
A = Left(A, 6) & "089"
Case 5
A = Left(A, 6) & "145"
Case 6
A = Left(A, 6) & "220"
Case 7
A = Left(A, 6) & "609"
Case 8
A = Left(A, 6) & "687"
Case 9
A = Left(A, 6) & "725"
End Select
H = "INSERT INTO 月网点借方汇总 ( 时间, 网点号, 交易类型, 借方业务量, 借方发生额合计 ) " _
& "SELECT " & Left(A, 6) & " AS 时间, " & Right(A, 3) & " AS 网点号, [" & A & "].交易类型, Count([借方发生额]*1) AS 借方业务量, Sum([借方发生额]*0.0001) AS 借方发生额合计" _
& " FROM " & A & " WHERE [借方发生额] * 1 > 0 GROUP BY [" & A & "].交易类型;"
MsgBox (H)
DoCmd.RunSQL (H)
Next X
End Sub |