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

cannot access the selected tables - error

Status
Not open for further replies.

borsker

Programmer
Jul 24, 2002
147
0
0
US
Building a form based on customers database that comes in from week to week. i created a list box that uses the dbf that was sent.
Here is what i have so far.
i created a form and added two command boxes and a list box. The code for the first command box works just fine
thisform.LIST1.rowSOURCE = 'filenames.filename'
thisform.LIST1.rowSOURCETYPE = 6

But when I try to use the second command box i get the "cannot access the selected tables. filenames.filename" when i try to do this
"USE filenames.dbf
SET FILTER TO ALLTRIM(filename)=(clistofnames)"

clistofnames by the way is the controlsource for the listbox. I did some research and tried adding this before any of my code on the second command box. "thisform.LIST1.rowSOURCE = ''

no success. any ideas?
 
Try either...
Code:
Select "FileNames"
Set Filter to Alltrim(filename) = clistofnames
Locate && apply filter

or

Code:
Set Filter to Alltrim(filename) = clistofnames in "FileNames"
go top in "FileNames" && apply filter

I suspect that your problem is that unneeded "Use Filenames.dbf".

boyd.gif

SweetPotato Software Website
My Blog
 
Hi Borkser,

First, when you talk about "command boxes", do you mean command buttons? If so, is the code you showed in fact the code in the Click events of those button?

If so, you definitely don't want to do a USE in that code. The code in a Click event will fire everytime the user clicks the button. If you USE the table at that point, you will be constantly opening and closing it, which is not what you want. You should move the USE command to the form's Load event. Just before setting the filter, you should SELECT the table.

For similar reasons, you don't want to keep on setting the rowsource and rowsourcetype in the buttons. You do that once only, probably in the listbox's Init.

If I have misunderstood what you are trying to do, perhaps you could clarify.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
you hit it right on the head craigsboyd. I used your second code. It worked perfectly. Mike, I never thought to use the load event, i will also do things a lot different from now on thanks.
 
The control source (alias) for the control is getting closed someplace. Tracking down where that is happening can be difficult.

Craig Berntson
MCSD, Visual FoxPro MVP, Author, CrysDev: A Developer's Guide to Integrating Crystal Reports"
 
craigber,

The code that borsker is using is where it is closing and reopening the alias. The Filenames table is already open, then borsker is using the table again (without a different alias and keyword AGAIN). So, in this case it wasn't as difficult to track down where it was happening.
Code:
USE (HOME(1) + "Samples\Northwind\customers.dbf")
GOTO 5
USE (HOME(1) + "Samples\Northwind\customers.dbf")
?RECNO() && returns 1 not 5 because table was closed and reopened


boyd.gif

SweetPotato Software Website
My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top