求助LotusScript
iuucc 2015-01-19 08:27:27 如何将下面代码修改成以"dh"为关键字来查询的,我是用Access数据库,在LotusScript建了个表格,希望把Accss数据库的数据读到表格中去,表格的每个单元格都创建了一个域,查询的结果放到指定的域中,可以分页显示的,谢谢了哈。。
Sub Click(Source As Button)
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
Dim str1 As String
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc=workspace.CurrentDocument
Set doc=uidoc.Document
msg="'"&uidoc.fieldgettext("dh") &"'"
con.ConnectTo("lb")
Set qry.Connection=con
Set result.Query = qry
a1=doc.gys(0)
a2=doc.ytr(0)
a3=doc.rq(0)
a4=doc.dh(0)
str1="select * from ytd where "
str2=""
If a1<>"" Then
str2=str2 & "gys=" & "'" & a1 & "'" & " and "
End If
If a2<>"" Then
str2=str2 & "ytr=" & "" & a2 & "" & " and "
End If
If a3<>"" Then
str2=str2 & "rq= " &"#"& a3 & "#" & " and "
End If
If a4<>"" Then
str2=str2 & "dh=" & "" & a4 & "" & " and "
End If
Str3="select * from ytd where "& str2
If a1="" And a2="" And a3=""And a4="" Then
Str3="select * from ytd"
Else
Str3=Left$(str3, Len(str3)-5)
End If
qry.SQL=str3
result.Execute
result.FirstRow
result.lastRow
n=result.NumRows
t=n Mod 5
yeshu=(n-t)/5
If t>0 Then
yeshu=yeshu+1
End If
If yeshu=0 Then
yeshu=1
End If
page=1
diyitiao=(page-1)*5+1
zuihoutiao=page*5
i=diyitiao
If i<=zuihoutiao And i<=n Then
result.CurrentRow=i
Call result.GetValue(1,a)
Call result.GetValue(2,b)
Call result.GetValue(3,c)
Call result.GetValue(4,d)
Call result.GetValue(5,e)
Call result.GetValue(6,f)
Call result.GetValue(7,g)
Call result.GetValue(8,h)
doc.dh=a
doc.gys=b
doc.ytr=c
doc.rq=d
doc.mc=e
doc.nb=f
doc.gg=g
doc.yy=h
i=i+1
End If
If i<=zuihoutiao And i<=n Then
result.CurrentRow=i
Call result.GetValue(5,e)
Call result.GetValue(6,f)
Call result.GetValue(7,g)
Call result.GetValue(8,h)
doc.mc_1=e
doc.nb_1=f
doc.gg_1=g
doc.yy_1=h
i=i+1
End If
If i<=zuihoutiao And i<=n Then
result.CurrentRow=i
Call result.GetValue(5,e)
Call result.GetValue(6,f)
Call result.GetValue(7,g)
Call result.GetValue(8,h)
doc.mc_2=e
doc.nb_2=f
doc.gg_2=g
doc.yy_2=h
i=i+1
End If
If i<=zuihoutiao And i<=n Then
result.CurrentRow=i
Call result.GetValue(5,e)
Call result.GetValue(6,f)
Call result.GetValue(7,g)
Call result.GetValue(8,h)
doc.mc_3=e
doc.nb_3=f
doc.gg_3=g
doc.yy_3=h
i=i+1
End If
If i<=zuihoutiao And i<=n Then
result.CurrentRow=i
Call result.GetValue(5,e)
Call result.GetValue(6,f)
Call result.GetValue(7,g)
Call result.GetValue(8,h)
doc.mc_4=e
doc.nb_4=f
doc.gg_4=g
doc.yy_4=h
i=i+1
End If
result.Close
con.Disconnect
uidoc.Refresh
End Sub