<DIV class=quote>以下是引用apeng在2005-10-10 20:04:00的发言:
Private Sub ChangeQry()
Dim qdfTemp As QueryDef
Dim st As String
Dim en As String
Dim c As Integer
Dim k As Integer
Dim x As Integer
Dim sql As String
Dim ss As String
If Not (IsNull(s) Or IsNull(e)) Then
sql = "SELECT ID, 字段1"
c = 1
If e > s Then
st = s
en = e
Else
st = e
en = s
End If
ss = "[" & st & "]"
sql = sql & ", " & ss
Do While st < en
k = Val(Mid(st, 1, 2))
x = Val(Mid(st, 4, 2)) + 15
k = k + x \ 60
x = x Mod 60
st = Format(k, "00") & ":" & Format(x, "00")
c = c + 1
ss = ss & " + [" & st & "]"
sql = sql & ", " & " [" & st & "]"
'Debug.Print st, c, ss, sql
Loop
sql = sql & ", " & "(" & ss & ")/" & c & " AS 平均收视率 FROM 报告备份;"
'Debug.Print sql
Set qdfTemp = CurrentDb.QueryDefs("查询1")
qdfTemp.sql = sql
Me.Child6.SourceObject = ""
Me.Child6.SourceObject = "查询.查询1"
End If
End Sub
[此贴子已经被作者于2005-10-26 13:37:30编辑过]
|