查询按钮无反应
每日醉茫茫 2014-04-04 01:06:32 小白一只,按照教程做的一个查询的数据库,但是点击查询按钮,一点反应也没有。请高人帮我看看是不是代码错了?
Private Sub Box70_Click()
End Sub
Private Sub cmd查询_Click()
On Error GoTo Err_cmd查询_Click
Dim strWhere As String '定义条件字符串
strWhere = "" '设定初始值-空字符串
'判断【图名】条件是否有输入的值
If Not IsNull(Me.图名) Then
'有输入
strWhere = strWhere & "([图名] like '*" & Me.图名 & "*') AND "
End If
'判断【旧图号】条件是否有输入的值
If Not IsNull(Me.旧图号) Then
'有输入
strWhere = strWhere & "([旧图号] like '*" & Me.旧图号 & "*') AND "
End If
'判断【新图号】条件是否有输入的值
If Not IsNull(Me.新图号) Then
'有输入
strWhere = strWhere & "([新图号] like '*" & Me.新图号 & "*') AND "
End If
'判断【比例尺】条件是否有输入的值
If Not IsNull(Me.比例尺) Then
'有输入
strWhere = strWhere & "([比例尺] like '*" & Me.比例尺 & "*') AND "
End If
'判断【档案号】条件是否有输入的值
If Not IsNull(Me.档案号) Then
'有输入
strWhere = strWhere & "([档案号] like '" & Me.档案号 & "') AND "
End If
'判断【类型】条件是否有输入的值
If Not IsNull(Me.类型) Then
'有输入
strWhere = strWhere & "([类型] like '" & Me.类型 & "') AND "
End If
'判断【地区】条件是否有输入的值
If Not IsNull(Me.地区) Then
'有输入
strWhere = strWhere & "([地区] like '*" & Me.地区 & "*') AND "
End If
'判断【备注】条件是否有输入的值
If Not IsNull(Me.备注) Then
'有输入
strWhere = strWhere & "([备注] like '*" & Me.备注 & "*') AND "
End If
'如果输入了条件,那么strWhere的最后肯定有" AND ",这是我们不需要的,
'要用LEFT函数截掉这5个字符。
If Len(strWhere) > 0 Then
'有输入条件
strWhere = Left(strWhere, Len(strWhere) - 5)
End If
'先在立即窗口显示一下strWhere的值,代码调试完成后可以取消下一句
Debug.Print strWhere
'让子窗体应用窗体查询
Me.子窗体.Form.Filter = strWhere
Me.子窗体.Form.FilterOn = True
Exit_cmd查询_Click:
Exit Sub
Err_cmd查询_Click:
MsgBox Err.Description
Resume Exit_cmd查询_Click
End Sub
Private Sub cmd清除_Click()
On Error GoTo Err_cmd清除_Click
'刘小军(Alex) 2003-5-22
'这里将使用FOR EACH CONTROL的方法来清除控件的值
'这在控件比较多的时候非常有用。
'================================
Dim ctl As Control
For Each ctl In Me.Controls
'根据ctl的控件类型来选择
Select Case ctl.ControlType
Case acTextBox '是文本框,要清空(注意,子窗体下面还有两个锁定的文本框不能赋值)
If ctl.Locked = False Then ctl.Value = Null
Case acComboBox '是组合框,也要清空
ctl.Value = Null
'其它类型的控件不处理
End Select
Next
'取消子窗体的筛选
Me.子窗体.Form.Filter = ""
Me.子窗体.Form.FilterOn = False
Exit_cmd清除_Click:
Exit Sub
Err_cmd清除_Click:
MsgBox Err.Description
Resume Exit_cmd清除_Click
End Sub
Private Sub Text26_Click()
End Sub
Private Sub 类型_Click()
End Sub
Private Sub 主体_Click()
End Sub