Option Compare Database Dim f
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) '先設定窗體的“鍵預覽”屬性為“是” '本過程將加快你的輸入速度 '如果按 ESCAPE 鍵,就關閉窗體 If KeyCode = vbKeyEscape Then closeAllSelectForm "SelectForm" End If End Sub
Private Sub List0_DblClick(Cancel As Integer) checkYouSelect End Sub
Private Sub List0_KeyPress(KeyAscii As Integer) '本過程實現(xiàn)全鍵盤操作 If KeyAscii = 13 Then checkYouSelect End If End Sub
Sub closeAllSelectForm(strFormName As String) '通用過程1 '本過程用來關閉所有的指定名稱的窗體 For Each objForm In Forms If objForm.Name = strFormName Then DoCmd.Close acForm, objForm.Name End If Next objForm End Sub
Sub checkYouSelect() '通用過程2 '檢測你的選擇 '如果發(fā)現(xiàn) suncount 列為 0(表示沒有下一層了) '就可以把你選定的產(chǎn)品名稱放到文本框中了 On Error Resume Next Set f = New Form_SelectForm Dim objForm As Form If List0.Column(0) = 0 Then Forms("testform").Text0.Value = List0.Column(2) closeAllSelectForm "SelectForm" Else f.Visible = True f.List0.RowSource = "SELECT btype.soncount, btype.UserCode, btype.FullName, btype.typeId FROM btype WHERE parid='" & List0.Value & "'" End If End Sub |