I want to be able to directly access a data source without having to add a control like a combo box to a form. I have been sucessful in accessing tables with the following code.
Dim rst as ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenStatic
rst.Open "Select field1 from TableName"
If rst!field1 = 25 then
perform some action
End If
The above works great.
However I have not been successful in linking /using a query. I have not been able to get the code to work.
Any ideas what I am doing wrong? I have a saved query in Access "on the front end of a split database" that I want to call to return certain records. I tried copying the actualt SQl code fomr the query into the above "open" statement and that didn't produce any results.
Thanks for the Help!
Dim rst as ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenStatic
rst.Open "Select field1 from TableName"
If rst!field1 = 25 then
perform some action
End If
The above works great.
However I have not been successful in linking /using a query. I have not been able to get the code to work.
Any ideas what I am doing wrong? I have a saved query in Access "on the front end of a split database" that I want to call to return certain records. I tried copying the actualt SQl code fomr the query into the above "open" statement and that didn't produce any results.
Thanks for the Help!