Records retrieved via SQL do not display in subform

C

CEJ

In Access 2002, I have a form with a subform on it that I want to have
display the results of a SQL query on an Access table. The query allows for
an inexact search based on the contents of a text field on the parent form.
In the code listed below,
the query runs correctly and successfully builds the recordset, but after I
set the
subform's record source to the query and issue the requery command for the
subform, the records do not display in the subform control. Any thoughts on
what
the problem might be?

Dim stNameLast As String
Dim stSQL As String
Dim rst As New ADODB.Recordset

stNameLast = Me.txtSrchNameLast

stSQL = "SELECT UserID, NameLast, NameFirst FROM tblUsers " & _
"WHERE (NameLast Like '" & stNameLast & "%')"

rst.Open stSQL, CurrentProject.Connection, adOpenStatic, adLockReadOnly,
adCmdText

Me.ctrlUserSearchSubform.Form.RecordSource = stSQL
Me.ctrlUserSearchSubform.Form.Requery
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top