|
-
Apr 30th, 2001, 10:10 AM
#1
Thread Starter
New Member
Speeding up Combobox Loads
I am having a 5-30 second delay when my forms open. I am loading about 4-5 combo boxes on the forms. I use stored procedures on SQL2000. The data being retrieved is very small. Each box only has 2 - 100 records each. In fact only 1 of them has around 100 the other 4 are more like 3-10 records. (only 3 fields per record). The actual retrieval of data is quick...it's getting paused loading the combobox.
I have used both methods I found here.
Do while not EOF and MoveLast get record count then a For statement. Both are equal in speed for me. What else can I look for???
Here is the code I'm using to load the box. It is public because other forms need to load the same data. I used a regular SELECT statement here to show what I'm pulling...it is a stored procedure on my system
Public Sub g_LoadCompany(ByRef r_cboCompany As ComboBox)
' PURPOSE: To load a combo box with the Company information
' INPUTS : r_cboCompany = the combo box to load
' ASSUMES: None
' RETURNS: None
' EFFECTS: r_cboCompany
On Error GoTo ErrorHandle
' Local Constants
Const c_strProcSig As String = mc_strModuleName & "g_LoadCompany"
' Local Variables
Dim cnHR As ADODB.Connection
Dim rstCompany As ADODB.Recordset
Dim strCode As String
Dim strName As String
Dim intIndex As Integer
Dim intRecordCount As Integer
Dim intLoop As Integer
Dim strCompany As String
Set cnHR = modGlobals.g_cnConnection
strCompany = "SELECT Co_intID, " & _
"Co_strName " & _
"FROM tblCompany"
Set rstCompany = New ADODB.Recordset
rstCompany.Open strCompany, cnHR, adOpenStatic, adLockReadOnly, adCmdText
'Here is where the pause occurs, runs very fast up to this point
rstCompany.MoveLast
intRecordCount = rstCompany.RecordCount
rstCompany.MoveFirst
For intLoop = 0 To intRecordCount - 1
intIndex = rstCompany.Fields("Co_intID").Value
strCode = rstCompany.Fields("Co_strName").Value
r_cboCompany.AddItem strCode
r_cboCompany.ItemData(r_cboCompany.NewIndex) = intIndex
rstCompany.MoveNext
Next intLoop
rstCompany.Close
Set rstCompany = Nothing
cnHR.Close
Set cnHR = Nothing
Exit Sub
ErrorHandle:
g_objError.RaiseError Err, c_strProcSig
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|