-
Hi, I have a combo box that I want to be populated with data of a certain field, dependent on what client number is currently being shown. I've tried a few things but really have gotten nowhere. If anybody can help, I sure would appreciate it.
Thanks
-
DAO or ADO? With or Without a Data Control (Data1) or ADO (Adodc1) data control? The answer to your question regardless of the above is quite lengthy, send an email to
[email protected]
and attach a small code sample and I will try
to answer? The short answer for DAO with a data control is simply to set the database name to the data control and the recordset(field) to the combo box respective properties.
and combo boxes properties
-
Hai
I hope you are trying to populate the combo box by passing the parameter [customer no or something].
I am not sure which object you are using DAO OR ADO.
Anyway open a recordset which is holding the result of your sql query.
then populate it to the combo box.
rs is recordset variable
do until rs.eof
combo1.additem rs(index).value
rs.movenext
loop
with regards,
karun
[This message has been edited by karunakaran (edited 01-05-2000).]
-
Maybe the following code will help you:
'this subroutine should be called to load or
'refresh the combo box of warranty no
Private Sub LoadWarrNo()
'Declare our variables
Dim dbProgram As New ADODB.Connection
Dim rsWarranty As New ADODB.Recordset
'Make the connection
dbProgram.Open "dsn=Program"
'Clear the combo box
cboWarranty.Clear
'request the warranty no with a SQL statement executed
'by the connection to the database
Set rsWarranty = dbProgram.Execute("select * from " & _
"Warranty order by Warranty_No")
'Set the global variable to the first warranty no
'since that is the one that will be displayed
intCurWarr = rsWarranty("idWarranty")
'Loop through the warranty no
Do Until rsWarranty.EOF
'Add the address to the combo box
cboWarranty.AddItem _
rsWarranty("Warranty_No")
'Add the id of the warr no to the item data
'property for the address
cboWarranty.ItemData(cboWarranty.NewIndex) = _
rsWarranty("idWarranty")
'Move to the next record
rsWarranty.MoveNext
Loop
'Close the db
dbProgram.Close
'set our save variable to indicate no saves should be done
'when the index is set
intSaveUpdate = 0
'Set to the first address
cboWarranty.ListIndex = 0
'set back to allow updates
intSaveUpdate = 1
End Sub