|
这里遇到点问题,上传不了附件,现在代码帖给你,你自己复制到VBA里.看看是不是这个效果.
Option Compare Database
Private b
Private Sub cmbpm_AfterUpdate()
Me.txtgg = Me.cmbpm.Column(2)
Me.txtph = Me.cmbpm.Column(3)
Me.cmbpm = Me.cmbpm.Column(1)
End Sub
Private Sub cmbpm_Change()
Dim a As String
a = Me.cmbpm.Text
Me.cmbpm.RowSource = "SELECT py, pm, gg, ph FROM tblspml " _
& "Where py like '*" & a & "*' Or pm like '*" & a & "*' Or gg like '*" & a & "*' Or ph Like '*" & a & "*' ORDER BY py"
Me.cmbpm.Dropdown
End Sub
Private Sub cmbpm_Enter()
Me.cmbpm.RowSource = "SELECT py, pm, gg, ph FROM tblspml ORDER BY py"
End Sub
Private Sub cmbpm_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyUp, vbKeyDown
Me.cmbpm.OnChange = ""
Case Else
Me.cmbpm.OnChange = "[Event Procedure]"
End Select
End Sub
Private Sub cmbpm_NotInList(NewData As String, Response As Integer)
Dim ctl As Control
Set ctl = Me!cmbpm
Response = acDataErrContinue
ctl.Undo
Me.cmbpm = b
Me.cmbpm.RowSource = "SELECT py, pm, gg, ph FROM tblspml ORDER BY py"
SendKeys ("{Tab}")
End Sub
|
|