Private Sub c1_Click()
On Error GoTo Err_c1_Click
Dim strWheres As String '定义条件字符串
strWheres = "" '设定初始值-空字符串
If Not IsNull(Me.xiao) Then
strWheres = strWheres & "([ " & Str(Me.Combo17) & " ] >= " & Me.xiao & ") AND "
End If
If Not IsNull(Me.da) Then
strWheres = strWheres & "([ " & Str(Me.Combo17) & " ] <= " & Me.da & ") "
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70
Me.cxct.Form.Filter = strWhere
Me.cxct.Form.FilterOn = True
Exit_c1_Click:
Exit Sub
Err_c1_Click:
MsgBox Err.DESCRIPTION
Resume Exit_c1_Click
End Sub
红色部分本应改是字段名,但是我想用函数方式表示不知道如何实现请您指点!
我的意思是红色部分本应该是字段名例如:性别、姓名、生日
我做了一个Combo,想利用combo来选择字段名,然后在以下过程中查询,[ ]中应该是字段名但是我想用combo的值代替,我该怎么做
If Not IsNull(Me.xiao) Then
strWheres = strWheres & "([ " & Str(Me.Combo17) & " ] >= " & Me.xiao & ") AND "
End If
If Not IsNull(Me.da) Then
strWheres = strWheres & "([ " & Str(Me.Combo17) & " ] <= " & Me.da & ") "
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70
Me.cxct.Form.Filter = strWhere
Me.cxct.Form.FilterOn = True
[此贴子已经被作者于2006-4-21 11:16:22编辑过]
|