• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

SQL Help in Excel

vijay.vizzu

Member
Dear All,

Below code works fine for me,and it adds values to drop down one by one. The question can i display the values which are shown in drop down in a range or cell.

[pre]
Code:
rs.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
Do While Not rs.EOF
'cmbRequest.AddItem rs.Fields(0)
With Worksheets("Template").Shapes("combo").ControlFormat
.AddItem rs.Fields(0)
End With
rs.MoveNext
Loop
Else
MsgBox "I was not able to find any unique Products.", vbCritical + vbOKOnly
Exit Sub
End If
[/pre]
 
I think i solved this problem, by adding for loop inside the do while loop,

[pre]
Code:
rs.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
Do While Not rs.EOF
For i = 1 To rs.RecordCount
Range("p" & i).Value = rs.Fields(0)
With Worksheets("Template").Shapes("combo").ControlFormat
.AddItem rs.Fields(0)
End With
rs.MoveNext
Next
Loop
Else
MsgBox "I was not able to find any unique Products.", vbCritical + vbOKOnly
Exit Sub
End If
[/pre]
 
Back
Top