|
发表于 2007-2-14 08:58:45
|
显示全部楼层
1.Alt + F11 →VBA
2.插入→标准模块(因为我用的是日文版,中文是我自己翻译的,可能和中文版的不一样)
3.把下面的code copy到新的模块里
4.把鼠标放在TestChrW上,按F5运行
Function TestChrW()
Dim i As Long
Dim str As String
Dim rs As New ADODB.Recordset
CreateTestTable
rs.Open "tbl_TestChrW", CurrentProject.Connection, adOpenDynamic, adLockOptimistic, adCmdTable
For i = 0 To 1000
rs.AddNew
rs("number") = i
rs("chrw") = ChrW(i)
rs.Update
str = str & " " & i & ":" & ChrW(i)
DoEvents
If i Mod 20 = 0 Then
Debug.Print str
str = ""
End If
Next
rs.Close
DoCmd.OpenTable "tbl_TestChrW"
End Function
Function CreateTestTable()
On Error Resume Next
Dim strSQL As String
strSQL = "drop table tbl_TestChrW"
CurrentProject.Connection.Execute strSQL
If Err <> 0 Then
Debug.Print Err.Description
End If
strSQL = "create table tbl_TestChrW (ID AUTOINCREMENT(1,1),[number] long, [ChrW] text(2))"
CurrentProject.Connection.Execute strSQL
If Err <> 0 Then
Debug.Print Err.Description
End If
End Function
---------------------------------------------------------------------------------------------------------------------------------------
code可能有简单的写法..
必须先打开macro |
|