ADO Recordset

Dalorax

Registered User.
Local time
Today, 03:01
Joined
Aug 8, 2005
Messages
12
I have the following code to access a table:

Dim strProduct As String
Dim rs As ADODB.Recordset
Dim intNum As Integer
Dim strSQL As String
strProduct = Me![ProductName]
Set rs = New ADODB.Recordset
strSQL = "[ProductName] = '" & strProduct & "'"
rs.Open "tblRMFG", CurrentProject.Connection, adOpenKeyset, _
adLockOptimistic, adCmdTable
With rs
.Find (strSQL)
If .RecordCount > 0 Then ...

Unfortunately the recordcount returns all records in this table "tblRMFG"

What have I missed here?
 
even though you are "defining" strSQL, you aren't using it.
You are using tblRMFG in place of the sql statment.

Try something like
Code:
strSQL = "Select * from tblRMFG where productname = " & strproduct
rs.Open strSQL, currentProject.connection....etc.


Code:
strSQL = "[ProductName] = '" & strProduct & "'"
rs.Open "tblRMFG", CurrentProject.Connection, adOpenKeyset, _
adLockOptimistic, adCmdTable

ttfn
Kicker
 

Users who are viewing this thread

Back
Top Bottom