提供一个其他的例子,可供你参考,里面有模糊查询点击下载此附件
主窗体代码
Private Sub Command24_Click()
更新
End Sub
Private Sub Command25_Click()
Me.leibie = Null
Me.clmc = Null
Me.je1 = Null
Me.je2 = Null
Me.chexing = Null
Me.chehao = Null
Me.xiucheng = Null
Me.cj = Null
Me.llrq1 = Null
Me.llrq2 = Null
更新
End Sub
Public Function 更新()
Me.frmchild.SourceObject = "frm_clgl_child"
End Function
Public Function 双击更新()
Dim sjCtn As String
sjCtn = Me.ActiveControl.Name
Controls(sjCtn) = Null
更新
End Function
子窗体代码
Private Sub Form_Open(Cancel As Integer)
Dim sjCXtj As String
sjCXtj = ""
If Not IsNull(Form_chaxunchuangti.llrq1) Then sjCXtj = sjCXtj & "领料日期>=[forms]![chaxunchuangti]![llrq1] AND "
If Not IsNull(Form_chaxunchuangti.llrq2) Then sjCXtj = sjCXtj & "领料日期<=[forms]![chaxunchuangti]![llrq2] AND "
If Not IsNull(Form_chaxunchuangti.je1) Then sjCXtj = sjCXtj & "金额>=[forms]![chaxunchuangti]![je1] AND "
If Not IsNull(Form_chaxunchuangti.je2) Then sjCXtj = sjCXtj & "金额<=[forms]![chaxunchuangti]![je2] AND "
If Not IsNull(Form_chaxunchuangti.leibie) Then sjCXtj = sjCXtj & "类别 LIKE '*' & [forms]![chaxunchuangti]![leibie] & '*' AND "
If Not IsNull(Form_chaxunchuangti.clmc) Then sjCXtj = sjCXtj & "材料名称 LIKE '*' & [forms]![chaxunchuangti]![clmc] & '*' AND "
If Not IsNull(Form_chaxunchuangti.chexing) Then sjCXtj = sjCXtj & "车型 LIKE '*' & [forms]![chaxunchuangti]![chexing] & '*' AND "
If Not IsNull(Form_chaxunchuangti.xiucheng) Then sjCXtj = sjCXtj & "修程 LIKE '*' & [forms]![chaxunchuangti]![xiucheng] & '*' AND "
If Not IsNull(Form_chaxunchuangti.chehao) Then sjCXtj = sjCXtj & "车号 LIKE '*' & [forms]![chaxunchuangti]![chehao] & '*' AND "
If Not IsNull(Form_chaxunchuangti.cj) Then sjCXtj = sjCXtj & "车间 LIKE '*' & [forms]![chaxunchuangti]![cj] & '*' AND "
If sjCXtj <> "" Then sjCXtj = " WHERE " & Left(sjCXtj, Len(sjCXtj) - 5)
Me.RecordSource = "SELECT * FROM qryclgl" & sjCXtj