If DoCmd.RunSQL can only be used for action queries,
how can you perform a simple SELECT (from a SQL table)
to return a table value to an Access function...?
Sorry, this seems too simple to me - I'm missing something here.... ?
To Open a table from code use the DoCmd OpenTable method.
DoCmd.OpenTable "table1", acViewPreview
To open an ADO recordset in VB code use the RecordSet Open method.
Dim cnn1 As ADODB.Connection
Dim rstEmployees As ADODB.Recordset
Dim strCnn As String
Dim varDate As Variant
' Open connection.
strCnn = "Provider=sqloledb;" & _
"Data Source=srv;Initial Catalog=Pubs;User Id=sa;Password=; "
Set cnn1 = New ADODB.Connection
cnn1.Open strCnn
' Open employee table.
Set rstEmployees = New ADODB.Recordset
rstEmployees.CursorType = adOpenKeyset
rstEmployees.LockType = adLockOptimistic
rstEmployees.Open "employee", cnn1, , , adCmdTable Terry Broadbent
Please review faq183-874.
"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.