Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: alan shulman
  Where is alan shulman?
 utica
 New York - United States
 alan shulman
 To: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 Tags
Subject: RE: Closing table issue in form
Thread ID: 289145 Message ID: 289154 # Views: 25 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Forms
Date: Tuesday, December 28, 2010 7:49:22 PM         
   


> > In my form I have some code that lets you browse a table, that is not in the data environment of the form (thats another table). I have this code in click:
> >
> > use 'interest table' IN 0 INDEX 'interest table' ALIAS int
>
> This part would throw an error if the table is already open, see also the Again clause and Used() in help.
>
> > SELECT int
> > brow
> > USE IN 0
>
> "Use In 0" does not close the alias you previously opened (but rather does nothing).
> You can "Use In int" in your case, or, since that alias is the currently selected one, just "Use".
>
>
> >
> > I did this so I only would close the 'interest table'. This seems to work, but when I get back to the main form I have a combobox with policy numbers that you select and have this method I created that is called in the interactivechange event:
> >
> > y=thisform.combo1.value
> >
> > SEEK y
> > IF ! FOUND()
> > MESSAGEBOX("POLICY NOT FOUND")
> > ENDIF
> >
> > thisform.refresh
> >
> > This refreshes the data to correspond to the policy you selected. The problem is, after I view the 'interest table', come back to my main form and select a policy, I get my "policy not found" message. When I clear that it brings up the new policy data, so it works. But I can't see why I'm getting that message when the policy is on the list.
> >
>
> Aside from the "int" alias probably having been left open by the first part of your code, the second part is unreliable anyway because it does not check what the currently selected work-area is.
> The best option is to use the Alias or In clauses/parameters of almost every relevant Vfp command / function:
>
>
If Not Seek( m.y, 'yourAlias', 'yourIndexTagName' )
>    && 
> Endif
> 

>
>
>
> hth
> -Stefan


Ok, so I need to establish a workarea and alias for the table I'm seeking? Like, in my init for the main form I would say something like "use 'valanntable' IN 1 INDEX 'valanntable' ALIAS val", then "if not seek(m.y, 'val', 'valanntable)"?

Also, I thought the "use in 0" would close the 'int' table because I did not name the table. How would I close that table otherwise? Do I want to say 'close tables'?

ENTIRE THREAD

Closing table issue in form Posted by alan shulman @ 12/28/2010 5:49:38 PM
RE: Closing table issue in form Posted by Stefan Wuebbe @ 12/28/2010 6:31:21 PM
RE: Closing table issue in form Posted by alan shulman @ 12/28/2010 7:49:22 PM
RE: Closing table issue in form Posted by Stefan Wuebbe @ 12/28/2010 8:07:25 PM
RE: Closing table issue in form Posted by alan shulman @ 12/28/2010 8:34:32 PM
RE: Closing table issue in form Posted by Ilya Rabyy @ 12/28/2010 10:28:10 PM
RE: Closing table issue in form Posted by Stefan Wuebbe @ 12/29/2010 1:46:25 PM
RE: Closing table issue in form Posted by Ilya Rabyy @ 12/28/2010 8:16:16 PM