【正文】
1)) Then .Text = (1) Else .Text = .Col = 2 If Not IsNull((2)) Then .Text = (2) Else .Text = .Col = 3 If Not IsNull((3)) Then .Text = (3) Else .Text = .Col = 4 If Not IsNull((4)) And CDbl((4)) 0 Then .Text = CDbl((4)) Else .Text = (4) End If .Col = 5 If Not IsNull((5)) Then .Text = (5) Else .Text = .Col = 6 If Not IsNull((6)) Then .Text = (6) Else .Text = .Col = 7 If Not IsNull((7)) And CDbl((4)) 0 Then .Text = CDbl((7)) Else .Text = (7) End If .Col = 8 If Not IsNull((8)) Then .Text = (8) Else .Text = Loop End IfEnd WithEnd Sub(5) 查詢子窗體代碼查詢子窗體是用來查詢庫(kù)房中圖書資料明細(xì)的。其運(yùn)行效果如圖741所示。圖741 查詢子窗體運(yùn)行效果在列表框中給出編號(hào)或年月日后,“查詢”按鈕的Click事件將給出與數(shù)據(jù)庫(kù)查找比較的結(jié)果。Private Sub Command1_Click()On Error GoTo cmderrorDim find_date1 As StringDim find_date2 As StringIf = True Then sqlfind = select * from 圖書資料 where 編號(hào) between 39。 amp。 _ Combo1(0).Text amp。 39。 amp。 and amp。 39。 amp。 Combo1(1).Text amp。 39。End IfIf = True Then find_date1 = Format(CDate(Comboy(0).Text amp。 amp。 _ Combom(0).Text amp。 amp。 Combod(0).Text), yyyymmdd) find_date2 = Format(CDate(Comboy(1).Text amp。 amp。 _ Combom(1).Text amp。 amp。 Combod(1).Text), yyyymmdd) sqlfind = select * from 圖書資料 where 購(gòu)買日期 between amp。 _ find_date1 amp。 amp。 and amp。 amp。 find_date2 amp。 End If sqlfind, conn, adOpenKeyset, adLockPessimisticUnload Mecmderror:If 0 Then MsgBox End IfEnd Sub運(yùn)行查詢子窗體時(shí),組合框中就已經(jīng)從數(shù)據(jù)庫(kù)中提取了貨單號(hào)和年月日兩個(gè)待查條件。Dim i As IntegerDim sql As StringIf findok = True Then End Ifsql = select * from 圖書資料 order by 編號(hào) desc = adUseClient sql, conn, adOpenKeyset, adLockPessimisticIf = False Then 39。 添加編號(hào) With rs_find Do While Not .EOF Combo1(0).AddItem .Fields(0) Combo1(1).AddItem .Fields(0) .MoveNext Loop End WithEnd IfFor i = 2001 To 2005 39。 添加年 Comboy(0).AddItem i Comboy(1).AddItem iNext iFor i = 1 To 12 39。 添加月 Combom(0).AddItem i Combom(1).AddItem iNext iFor i = 1 To 31 39。 添加日 Combod(0).AddItem i Combod(1).AddItem iNext iEnd Sub查詢完畢后,輸出查詢結(jié)果,如圖742所示。圖742 查詢結(jié)果圖表