Slow Loop processing in the ComboBox Change event

L

Lant

Using Visio 2003 and VBA 6.3
I am trying to populate a Textbox (TextBoxPackageInfo) based on the user
selection made in a ComboBox (the selection is stored in a public variable-
ThisDocument.packageSelection ) on the same form (FormPackageSelection). I
have the following code in the CHANGE event of the combobox. The code works
but seems to be taking a long time to go thru the loop (shown in the code
below) and
refresh the Text box when an update is made. I am new to VBA, Data Access
Object, and Visio. Please provide feedback on any wrong approaches you see in
this code which could fix the problem.


===================================================================================================

strSelect = "SELECT DISTINCT productname FROM prodtable WHERE packagename=
'" &
ThisDocument.packageSelection & "';"

'Open the Details table (Record Set)
Set rsDetails = ThisDocument.db.OpenRecordset(strSelect)

'Populate the Package Details from the record set
FormPackageSelection.TextBoxPackageInfo.Text = " "

tempString = " "
Do Until rsPackageDetails.EOF
tempString = tempString & Trim(rsPackageDetails!ProductName) & vbCrLf &
" "
rsPackageDetails.MoveNext
Loop

FormPackageSelection.TextBoxPackageInfo.Text = tempString


=====================================================
 
A

Al Edlund

Consider time stamping at each step (selection, read, update, etc) to
identify where the delay is. It certainly doesn't sound like a visio (or
vba) problem.
Al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top