T
Tom
I am using the "Search Form" that was designed by Terry Kreft and Dev Ashish
(http://www.mvps.org/access/forms/frm0045.htm).
I have added the 2nd line of code "DoCmd.DeleteObject acQuery,
"qryKeywordSearch" so that I can link a report to the query (hence it will
always show the latest selected criteria.
I have 2 questions now:
1. What line(s) of code need to be added in order to automatically add a
"Description" in the properties?
2. What line(s) of code need to be added to automatically check the "Hidden
Attribute" in the properties?
Thanks,
Tom
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Private Sub cmdCreateQDF_Click()
DoCmd.DeleteObject acQuery, "qryKeywordSearch"
On Error GoTo ErrHandler
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strName As String
'first get a unique name for the querydef object
strName = Application.Run("acwzmain.wlib_stUniquedocname", "Query1",
acQuery)
strName = InputBox("Please specify a query name", "Save As", strName)
If Not strName = vbNullString Then
'only create the querydef if user really wants to.
Set db = CurrentDb
Set qdf = db.CreateQueryDef(strName, Me.txtSQL)
qdf.Close
Else
'ok, so they don't want to
MsgBox "The save operation was cancelled." & vbCrLf & _
"Please try again.", vbExclamation + vbOKOnly, "Cancelled"
End If
ExitHere:
On Error Resume Next
qdf.Close
Set qdf = Nothing
db.QueryDefs.Refresh
Set db = Nothing
Exit Sub
ErrHandler:
Resume ExitHere
End Sub
(http://www.mvps.org/access/forms/frm0045.htm).
I have added the 2nd line of code "DoCmd.DeleteObject acQuery,
"qryKeywordSearch" so that I can link a report to the query (hence it will
always show the latest selected criteria.
I have 2 questions now:
1. What line(s) of code need to be added in order to automatically add a
"Description" in the properties?
2. What line(s) of code need to be added to automatically check the "Hidden
Attribute" in the properties?
Thanks,
Tom
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Private Sub cmdCreateQDF_Click()
DoCmd.DeleteObject acQuery, "qryKeywordSearch"
On Error GoTo ErrHandler
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strName As String
'first get a unique name for the querydef object
strName = Application.Run("acwzmain.wlib_stUniquedocname", "Query1",
acQuery)
strName = InputBox("Please specify a query name", "Save As", strName)
If Not strName = vbNullString Then
'only create the querydef if user really wants to.
Set db = CurrentDb
Set qdf = db.CreateQueryDef(strName, Me.txtSQL)
qdf.Close
Else
'ok, so they don't want to
MsgBox "The save operation was cancelled." & vbCrLf & _
"Please try again.", vbExclamation + vbOKOnly, "Cancelled"
End If
ExitHere:
On Error Resume Next
qdf.Close
Set qdf = Nothing
db.QueryDefs.Refresh
Set db = Nothing
Exit Sub
ErrHandler:
Resume ExitHere
End Sub