我有一个Modal和Pop up的表单(然后是隐藏背景的附加代码),因此客户端只能看到表单。
在此表单上,我有一个按钮,它使用以下代码根据文本框中的关键字运行查询。
Private Sub Command12_Click()
Dim strsearch As String
Dim Task As String
Dim rs As Recordset
Dim dbs As Database
Dim qdf As QueryDef
Set dbs = CurrentDb()
strsearch = Me.Text13.Value
Task = "SELECT GrantInformation.GrantRefNumber, GrantInformation.GrantTitle, GrantInformation.StatusGeneral, GrantSummary.Summary "
Task = Task & "FROM GrantInformation LEFT JOIN GrantSummary ON GrantInformation.GrantRefNumber = GrantSummary.GrantRefNumber "
Task = Task & "WHERE (((GrantInformation.LeadJointFunder) = 'Global Challenges Research Fund')) Or (((GrantInformation.Call) = 'AMR large collab')) "
Task = Task & "GROUP BY GrantInformation.GrantRefNumber, GrantInformation.GrantTitle, GrantInformation.StatusGeneral, GrantSummary.Summary "
Task = Task & "HAVING (((GrantSummary.Summary) Like ""*" & strsearch & "*"")) OR (((GrantSummary.Summary) Like ""*" & strsearch & "*""));"
Set rs = dbs.OpenRecordset(Task, dbOpenSnapshot)
With dbs
Set qdf = .CreateQueryDef("tmpProductInfo", Task)
DoCmd.OpenQuery "tmpProductInfo"
.QueryDefs.Delete "tmpProductInfo"
End With
dbs.Close
qdf.Close
End Sub
这一切都很完美。但它显示了Access应用程序并在那里显示查询(我不希望他们看到Access应用程序)。
运行时是否可行:
DoCmd.OpenQuery "tmpProductInfo"
使用VBA在自己的窗口中弹出它?
非常感谢!