Office中国论坛/Access中国论坛

标题: 遇到一问题花费我好长的时间请各位帮个忙 [打印本页]

作者: sunguochang    时间: 2002-11-11 19:07
标题: 遇到一问题花费我好长的时间请各位帮个忙

Dim strsql As String
Dim rst As New ADODB.Recordset
    Dim dt1, dt2 As Date
    strsql = "select top 1 date from ld_colour_history where event_
like'%REC%' ORDERBY date"
    rst.Open strsql, CurrentProject.Connection, adOpenStatic, adLockReadOnly
dt1 = rst.Fields("Date")
rst.Close
    strsql = "select top 1 date from ld_colour_history where event_
like'%SUB%' ORDERBY date desc"
    dt2 = rst.Fields("date")
rst.Close
strsql = "select * from LD_COLOUR_HISTORY where (hld='" & HLD.Value & "')_
and (colour='" & Colour & "')"
    rst.Open strsql, CurrentProject.Connection
    Dim i As Integer
       Do Until rst.EOF
        i = i + 1
        UCase (rst.Fields("event")) Like "%REC%"
        rst.MoveNext
    Loop
MsgBox DateDiff("d", dt1, dt2) / (i / 2)
文件下载[em26]


[此贴子已经被作者于2002-11-11 11:07:24编辑过]


作者: 李寻欢    时间: 2002-11-18 19:30
你要加上
Dim cn As Connection
Set cn = CurrentProject.Connection
然后变黄那行改成:
rst.Open strsql, cn, adOpenStatic, adLockReadOnly






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