|
局域网访问ACCESS,下面代码该怎样修改?
Public TotalMode As Integer
Public Modify As Boolean
Public cnnAccess As Object
Public rstAnswers As Object
Public strSQL As String
Sub Open_Accessjcf() '打开数据库
Dim Stpath As String
Set cnnAccess = CreateObject("Adodb.Connection")
Stpath = ThisWorkbook.Path & Application.PathSeparator & "jcf.mdb" '设定路径
cnnAccess.Provider = "Microsoft.Jet.OLEDB.4.0"
cnnAccess.Open "Data Source =" & Stpath & ";Jet OLEDBatabase Password=" & ""
End Sub
Sub 更新()
Open_Accessjcf
Set rstAnswers = CreateObject("Adodb.Recordset")
strSQL = "Select * From jc"
rstAnswers.Open strSQL, cnnAccess
Y = 0
Do Until rstAnswers.EOF = True
Sheet3.Cells(Y + 2, 1).Value2 = rstAnswers(0)
Sheet3.Cells(Y + 2, 2).Value2 = rstAnswers(1)
Sheet3.Cells(Y + 2, 3).Value2 = rstAnswers(2)
Sheet3.Cells(Y + 2, 4).Value2 = rstAnswers(3)
Sheet3.Cells(Y + 2, 5).Value2 = rstAnswers(10)
Sheet3.Cells(Y + 2, 6).Value2 = rstAnswers(11)
Y = Y + 1
rstAnswers.MoveNext
Loop
Set rstAnswers = Nothing
MsgBox "报告!数据更新完毕,请继续操作,谢谢。"
End Sub
|
|