[attach]54044[/attach]
如图,我创建两个窗口,第一个窗口实现具体的表筛选并打开该表,第二个窗口实现了对该表字段的筛选并建立查询,
生成查询的代码是:
Private Sub Command10_Click()
Dim db As Database
Dim qdf As QueryDefs
Set db = CurrentDb
s2 = "select "
For i = 0 To Me.List1.ListCount - 1
s2 = s2 & Me.List1.Column(0, i) & ","
Next i
s2 = Mid(s2, 1, Len(s2) - 1) & " from " & TabName
Dim tmp1 As String
temp1 = " select * from " & TabName
If s2 <> "select from " & " & TabName & " Then
On Error Resume Next
DoCmd.DeleteObject acQuery, "自动生成的查询"
Set qdf = db.CreateQueryDef("自动生成的查询", s2)
DoCmd.OpenQuery "自动生成的查询"
End If
Set db = Nothing
End Sub
现在我想将第二个窗口建立的查询,根据第一个窗口文本框中的内容建立模糊查询,例如像图中那样,变成只显示井名为武4数据,该怎么改代码。
上传附件,求高手看一看。
[attach]54043[/attach]