Displaying all records in a form from an open recordset

chathag

Registered User.
Local time
Today, 18:10
Joined
May 22, 2009
Messages
32
I have the following piece of code that returns data based on the value of ComboBox1

Combobox1 contains a list of numeric values that also include operators. the list is as follows:

<=100
<90
<80
<70
<60

Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset

Rs.Open "SELECT Table1.* FROM Table1 WHERE field1 '" & ComboBox1 & "'", Application.CurrentProject.Connection, adOpenDynamic, adLockOptimistic, adCmdText

textbox1 = Rs("Field1")
textbox2 = Rs("Field2")
textbox3 = Rs("Field3")
textbox4 = Rs("Field4")
textbox5 = Rs("Field5")

Rs.Close

when the code is run I am returning the data to textboxes within a form. The problem I have is
that only the first record is shown on the form, and I am unable to return all records in the format of
a continuous form. I am assuming that I must create some sort of loop using BOF and EOF to run through
records.
Your assistance will be most appreciated.

Regards

GC
 
Is the combobox bound to the form or is it unbound? If you want to display the results on the same form as the combobox then you will probably need to display them in a subform. I've modified the database that I provided in your last thread and attached it; please see form1. Please let us know if it is what you are looking to do.
 

Attachments

  • Like
Reactions: SOS
Is the combobox bound to the form or is it unbound? If you want to display the results on the same form as the combobox then you will probably need to display them in a subform. I've modified the database that I provided in your last thread and attached it; please see form1. Please let us know if it is what you are looking to do.

jzwp22 -

Good example and way simpler than the ADO recordset method that the OP was trying. Thumbs up to you!
 
SOS,

Thanks. I hope the OP finds it useful!
 

Users who are viewing this thread

Back
Top Bottom