Article ID: 118367
Article Last Modified on 1/19/2007
Dim MyProp as Property
...
Set MyProp = MyQD.CreateProperty("LogMessages", DB_BOOLEAN, True)
MyQD.Properties.Append MyProp
After MyProp is appended to the Properties collection of MyQD, use the
following syntax when you reference the LogMessages property:
MyQD.Properties("LogMessages") = True
Option Explicit
Function MyFunct ()
Dim MyDB as Database
Dim MyQD as QueryDef
Set MyDB = CurrentDb()
Set MyQD = MyDB.CreateQueryDef("QueryName")
MyQD.connect = "ODBC;DSN=Server_Name;UID=UserName; _
PWD=MyPassword; DATABASE=DB_Name"
MyQD.sql = "SELECT * from TableName"
MyQD.returnsrecords = True
' The following line generates the error message
MyQD.LogMessages = True
MyQD.Close
End Function
The following sample code demonstrates how to change the sample code above
to set the LogMessages property correctly:
Option Explicit
Function MyFunct2 ()
Dim MyDB as Database
Dim MyQD as QueryDef
' Dimension a variable as type Property.
Dim MyProp as Property
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MyQD = MyDB.CreateQueryDef("QueryName")
' Create a Boolean property called LogMessages.
Set MyProp = MyQD.CreateProperty("LogMessages",DB_BOOLEAN,True)
' Append the property to the QueryDef variable.
MyQD.Properties.Append MyProp
MyQD.connect = "ODBC;DSN=Server_Name;UID=UserName; _
PWD=MyPassword; DATABASE=DB_Name"
MyQD.sql = "SELECT * from TableName"
MyQD.returnsrecords = True
' Set a value for the property you just created
MyQD.Properties("LogMessages") = True
MyQD.Close
End Function
Keywords: kberrmsg kbprb kbprogramming kbusage KB118367