-
do while loop
I only want to place the first three records in my comboBox, but this code places all the records in there:
Code:
Do While objDR.Read = True
Me.cmbCards.Items.Add(Trim(objDR("employee_first_name"))
loop
so, I changed the code to:
Code:
Do While counter < 2
Me.cmbCards.Items.Add(Trim(objDR("employee_first_name"))
counter = counter + 1
Loop
but this returned an err msg....no data found...anyone have the proper syntax to do this?
thanks
-
I think the reason why it is falling over is because you are not calling the objDR.Read method in the second example while you are looping round
Try:
Code:
Do While counter < 2 and objDR.Read
Me.cmbCards.Items.Add(Trim(objDR("employee_first_name"))
counter = counter + 1
Loop
-
Why not just use TOP 3 in your SQL Query.
-
thanks VBCoder...Edneeis...theres a TOP command is SQL? Do you have a example?
-
SELECT TOP 3 * FROM MyTable
-
did not know that...thanks