Manipulating DataCombo Box at Run Time

fbk2000
fbk2000 used Ask the Experts™
on
Here's the problem.  I have a datacombo bound to an ADO Control bound to an Excel sheet.  Everything works fine, except that I want to be able to reset the datacombo such that the first thing listed is once again listed in the box (i.e. reload the datacombo)  I've tried a few things that seem to work just fine within the IDE, but once I compile, they don't reset the text in the datacombo at all.  What's going on?

For example....

The first thing listed in the datacombo is "Select State"

then the user selects from a list of states provided by the excel sheet

But if the user presses a refresh button, I want to be able to revert the text back to "Select State"

I'm not sure why I can't get this to work outside of the IDE
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
What is the refresh button code doing?  My first thought is that the recordset cursor is not being moved.  Have you tried adodc.recordset.movefirst in the Refreshbutton_click event code?  
why not Create a function to populate the combo box from the recordset at runtime. and then call the recordset as the form loads, then if they hit refresh all you have to do is call the function again.

recordset : name of your recordset
item : name of the field you are using to populate the box

Public function loadcombo(recordset)
   do while not recordset.eof
      add.item recordset("item")
      recordsetset.movenext
   loop
end function

Author

Commented:
That's exactly what I ended up doing.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial