设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 766|回复: 1
打印 上一主题 下一主题

[其它] EXCEL局域网访问ACCESS

[复制链接]
跳转到指定楼层
1#
发表于 2006-7-15 19:38:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
局域网访问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
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
 楼主| 发表于 2006-7-15 19:55:00 | 只看该作者
请教
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-11-11 01:18 , Processed in 0.094075 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表