Office中国论坛/Access中国论坛

标题: 请高手帮我改一下程序 [打印本页]

作者: cangqiong    时间: 2008-4-25 09:46
标题: 请高手帮我改一下程序
这是个EXCEL的模块,请高手帮我改一下,不知为什么出错

Sub 系列()
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")
    Set RS = DB.OpenRecordset("部品")
      ING1 = Application.ActiveCell.Column
    For xh = 1 To 100
        If UCase(Cells(1, xh)) = "HINBAN" Or Cells(1, xh) = "型号" Or Right(Cells(1, xh), 2) = "型号" 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 = DLookup("[系列]", "部品", "[型号]='" & Va & "'")   执行到这就出错
         Cells(Row, ING1) = Strsql
        
            Next
退出:
    Set RS = Nothing
    Set DB = Nothing
    Application.DisplayAlerts = true
    Application.ScreenUpdating = true
    Exit Sub
错误_Err:
    MsgBox Error$
    Resume 退出:
End Sub




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