I am trying to store my queries in a table using some code from the Access Cookbook by Getz, Litwin & Baron.
tblQueries has the following fields:
QueryID - AutoNumber, Primary Key
QueryName - text
QueryDescription - text
SQLText - Memo
DateCreated - Date/Time
The procedure I am using to get the SQL string is:
Public Function acbGetSavedQuerySQL(strName As String) As String
' Returns a SQL string from tblQuerySQL
' In : strName - name of query to retrieve
' Out : SQL string
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("tblQueries")
rst.Index = "PrimaryKey"
rst.Seek "=", strName
If Not rst.NoMatch Then
acbGetSavedQuerySQL = rst!QrySQLText
End If
rst.Close
Set rst = Nothing
Set db = Nothing
End Function
The event I am using to run the SQL is:
Private Sub cmdGetQryShiningStarBirthdate_Click()
DoCmd.RunSQL acbGetSavedQuerySQL("Test")
End Sub
The error I am getting is:
Data type conversion error and when I debug it highlights this line of code:
rst.Seek "=", strName
I am still learning VBA and have been unable to problem solve this one on my own.
Thank you to anyone who can provde some help!
Heather