On a form, I have a command button that has the following event onClick:
Private Sub Command0_Click()
Dim rslt As ADODB.Recordset, sqlstr As String
sqlstr = "SELECT Table1.id, Table1.name, Table1.value FROM Table1
WHERE Table1.name like '%" & Text1.Value & "%'"
Set rslt = New ADODB.Recordset
Set rslt.ActiveConnection = CurrentProject.Connection
rslt.Open sqlstr
MsgBox rslt.RecordCount
End Sub
No matter what I enter into the Text1 box (on the form), I always get a
RecordCount of -1.
So, I created a query by selecting SQL view and pasting in:
SELECT Table1.id, Table1.name, Table1.value FROM Table1 WHERE
Table1.name like '%jo%'
When I run the query, I get 6 rows returned.
What (likely obvious) detail am I missing here? I threw in a MsgBox
sqlstr to be sure that the query looks exactly as it should...
--
Justin Koivisto - ju****@koivi.com
http://koivi.com