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")
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)
’我这段代码实现以下三个功能:
’1,先检查表LD_COLOUR_HISTORY中字段名为“event"中“*REC*”出现的次数,得出‘“*REC*”出现的次数为i
’2,然后检查表ld_colour_history字段名为“EVENT”中“RECEVIED LD"第一次出现的日期
’3,然后检查表ld_colour_history字段名为“EVENT”中“*SUB*"最后一次出现的日期
[em26][em26]
[em26][em26]
[此贴子已经被作者于2002-11-8 13:51:39编辑过]
|