Problems using set Formabc.Recordset = thisRS when using a combo box

johnbtic

New member
Local time
Yesterday, 18:45
Joined
Dec 7, 2011
Messages
19
Hi all


I'd like to use a combobox to select a record. Then using the contents of the combobox to find a record in a recordset, this piece seems to work. But when I use the following command
Set FormABC.Recordset = thisRS


The contents of the bound text boxes on the form produce a '#Name?' inside them. The weird thing is that when I've done it but not using a combobox in the past but a text box, this seems to work. I"ve changed the text box as a test to a combobox and left everything else the same, and then it doesn't work.


Any ideas?

Many thanks


John
 
Hi John. Can we see your code please? Thanks.
 
I've been struggling with this for weeks and on a whim I just tried something and it worked. The command I was using was

Set thisRS = thisDB.OpenRecordset("SELECT * FROM qryPropertiesTabular ORDER BY [tblProperties.ID]")
And I removed the ORDER BY and used
Set thisRS = thisDB.OpenRecordset("SELECT * FROM qryPropertiesTabular")


And this worked...
 
For the record here's the code
Dim strProp As String, strSQL As String

Dim thisDB As DAO.Database
Dim thisRS As DAO.Recordset

Set thisDB = CurrentDb()
Set thisRS = thisDB.OpenRecordset("SELECT * FROM qryPropertiesTabular")

' Take button click from frmManagePeople, search text in textbox in People table
strProp = Me.combobox_frmPropertiesTabular_PropertyName

' Determine search criteria in inputted string of 'FindFirst' command
strSQL = "tblProperties.txtName = " & "'" & strProp & "'"

' Do a search for SQL string
thisRS.FindFirst strSQL

Set Form_subfrmPropertiesTabular.Recordset = thisRS

' -------------------------------
' Cleanup
' Don't include the following two lines. If not commented out code doesn't work.
' thisRS.Close
' thisDB.Close

Set thisRS = Nothing
Set thisDB = Nothing
 
Hi. Glad to hear you got it sorted out. Good luck with your project.
 
Thanks DBGuy and thanks so much for your rapid response it's much appreciated :)


I'm sure I'll be back!!
 
There's no need to open a recordset if you use the form's recordset clone

Code:
dim frm as Form
set frm= forms!subfrmPropertiesTabular

frm.recordsetclone.findfirst "tblProperties.txtName = '"  &  Me.combobox_frmPropertiesTabular_PropertyName & "'"
frm.recordset.bookmark = frm.Recordsetclone.bookmark

Alternatively, you could also apply a filter to the sub form
 

Users who are viewing this thread

Back
Top Bottom