Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use ADODB.Recordset as RowSource for combo box 1

Status
Not open for further replies.

lewatkin

Programmer
Mar 8, 2002
91
US
Hi all,

I am trying to use an ADODB recordset as a rowsource for a combo box. I can loop through the recordset and write the values to a table just fine, but that is not what I need to do. Here is the code:

Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "Driver=iSeries Access ODBC Driver;System = Server1;", "uname", "pword"
cn.CursorLocation = adUseClient

strSQL = "SELECT LIBRARY.LOGFILE.* FROM LIBRARY.LOGFILE"

rs.Open strSQL, cn, adOpenStatic, adLockReadOnly

All of that works - now how do I use it? :)

If someone could just get me going in the right direction as I am not very proficient w/ADO.

Thanks a ton in advance!!
 
Have you tried looping until EOF, using cbo.AddItem in each iteration to populate the data?

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
I have not and did not even THINK about that. Man I appreciate you pointing me in that direction. I'll give it a shot.
Have a star...

Thanks man!!
 
[cheers]

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Tyrone, if you play with controls, it's safer to use the Load event instead of Open.
 
The list of data that I am using is constantly changing (like several times / minute). I am actually using it on the click event of the combo box. Max records will only ever be 500 and the list populates in milliseconds. Using ADO keeps the recordset on the server side and all that is passed over the network is the individual values, so that is going to work for me. However, I do agree with PHV on using the Load event for a lot of tasks. Using the open event sometimes forces unnecessary queries prior to the form being displayed, and can subsequently slow down the 'opening' time of the form. That has been my experience and that's my 2 cents :)

Thanks for everything gang!! I love coming here because I know I can ALWAYS get good, reliable information. All of yall are awesome!!

Lee
 
Furthermore when the Open event fires the form (and thus its controls) aren't yest Loaded ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top