Office中国论坛/Access中国论坛

标题: 在EXCEL里调用ACCESS帮帮忙 [打印本页]

作者: cangqiong    时间: 2008-2-22 08:16
标题: 在EXCEL里调用ACCESS帮帮忙
这段代码是写在EXCEL里的。有些问题能帮我改一改吗?


Sub ZHP正式系列()
    On Error GoTo err
    Application.DisplayAlerts = False
    Application.ScreenUpdating = False
    Dim DB As Database
    Dim RS As Recordset
    Dim Va As String
    Dim Strsql As String
   
    Set DB = OpenDatabase("D:\数据库.mdb")
    ING1 = Application.ActiveCell.Column
    For xh = 1 To 100
        If Cells(1, xh) = "型号"  Then ing2 = xh: Exit For
        
    Next
    row_e = Cells(65536, ing2).End(xlUp).Row
    For Row = 2 To row_e
        Va = Cells(Row, ing2)
        
        Strsql = Nz(DLookup("[正式系列]", "ZHP", "[ZPXHAO]='" & Va & "'"))    '程序在这有时错误,有时可以运行

                    Cells(Row, ING1) = Strsql
            Next
退出:
    Set DB = Nothing
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    Exit Sub
err:
    MsgBox Error$
    Resume 退出:
            
        
        
End Sub
作者: cangqiong    时间: 2008-2-22 11:07
顶一下!!!!!!!!!!!!!!!!!!!!!!1




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3