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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combo box losing it's rowsource

Status
Not open for further replies.

DMSReed

Programmer
Mar 18, 2005
10
US
I have a form and am using a combo box to specify a search condition for a file to export. The rowsource is a table, the rowsource type is 6 (fields). The ControlSource is blank as I am not updating anything, just gathering data. The report runs fine the first time, but the combobox loses it's rowsource. The next consecutive time I attempt to run the report the data in the combobox is from a specific field in the table that contains all the report information, not the original rowsource table.

Searched this site but didn't find anything that may lead me in the right direction. Any help would be appreciated.

Scott
(using VFP 5)
 
Another way to debug this without changing your code is to put:

USED("the alias")

in the Watch window and set a breakpoint on it.

Tamar
 
Thanks for the suggestions. However, I will have to read more about using the debugger to follow Tamar's suggestion. I couldn't quickly determine how to set a breakpoint on the Watch window. I couldn't determine anything else after following Mr. Higgins instructions, so I'll add some more specifics.

I am not printing any data as I'm merely exporting it to Excel. I am creating a cursor based on the information found that matches the search criteria (from the combo box). The data is found and exports just fine. When the routine completes the form is refreshed and is ready for additional use. If I switch back to design mode the rowsource is still correct. If I run the form again from design mode it works fine. It's only if I try to run it consecutively that it shows the data from another field in a table different than the rowsource for the combo box being used.

My rowsource table is in the data environment for this form while the other tables are opened programatically. There are 2 other tables opened during this process with one of them being updated with simple replace commands based on data in various fields. When the updates are complete the data is exported. The only job of the rowsource table is to provide the selection criteria for the data to be exported.

I hope this additional explanation provides more clarity to help any of you help me!

Thanks,
Scott
 
Try this:

On the TOOLS MENU choose DEBUGGER.

Look for the box that says WATCH.

There is a text box to the right of it, type in what Tamar listed, USED("the alias") (fill in the alias of the control source),and press enter.

To the left of the line that USED("the alias") sits on click with the mouse until a red dot appears, this sets the BREAKPOINT, which means the code will stop whenever this dbf is used.

Run the form, it will stop whenever this changes.

Once it changes you should see whatever code caused the change. To step through the code click on the icon that is the 4th over from the left called STEP INTO, this will advance the code one line at a time.

It seems complicated but once you do this a few times it is actually fairly easy.


Don Higgins
 
Thanks for taking the time and explaining this to me Don. Very simple once I got pointed in the right direction. And the problem is now fixed. The form loads the correct rowsource since it's in the data environment. But when I was opening the additional tables during the routine I started by placing the first one in area 1 (Select 1). This bumped out the default table (the correct rowsource). I have since modified the code to ensure the correct table stays loaded.

Thanks again for your help!

Regards,
Scott
 
In general, it's a good idea to never refer to work areas by their numbers and never open tables in particular work areas. Instead, use code like:

USE MyTable IN 0
...

SELECT MyTable

Tamar
 
Thank you Tamar. I appreciate the guidance and agree with your suggestion.

Regards,
Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top