Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jamie Osborn
  Where is Jamie Osborn?
 Jamie Osborn
 To: Oxy-
  Where is Oxy-?
Subject: RE: how to use many remote views in one form????
Thread ID: 15983 Message ID: 15997 # Views: 1 # Ratings: 0
Version: Unknown Category: General VFP Topics
Date: Sunday, October 06, 2002 12:10:23 PM         

> Hi,
> I have a form with ~10 remote views.. they are being used for data retrieval and for data insertion (APPEND). it all worked perfectly, but suddenly, when i added more views strange things started to happen. Errors about inserting duplicate id values, grids turning into blank.. and some other stuff. As I understand I messed up something workspaces? I'm new to foxpro and whole workspace idea is strange to me. Please help, what code should I write to requery some views, then insert into the other view some values and so on...
> This always tells me about duplicate values:
> SELECT sut_insert
> USE sut_insert
> APPEND BLANK IN sut_insert
> REPLACE sut_insert.company_id WITH THISFORM.company_id, ;
> sut_insert.domainas WITH sdomainas ;
> IN sut_insert
> I think this is wrong too:
> SELECT firms
> p_Firms_CompanyID=THISFORM.company_id
> REQUERY("firms")
> USE firms IN 0
> * ...
> As you can see, I don't understand where to use "SELECT" and where "USE", the same for "IN". I would appreciate it, if someone could lighten me up.
> Please Help...
> Oxy-

USE actually opens a table/view. You should only be doing it once (usually) - the preferable method of opening it would be to add it to the data environment of the form - the data environment will automatically open & close the view/table and you need never issue a USE in code. For parameterised views (which it appears you are using) you can set the NoDataOnLoad property to .T. and then REQUERY() the view once you have set the memory variable (eg. p_Firms_CompanyID) to the right value.

SELECT sets the work area to the specified view/table. In your example you SELECT sut_insert and then USE sut_insert. This makes no sense. Once sut_insert has been opened then all you need to do is SELECT it. In fact, in your example you don't even need to SELECT it as your APPEND and REPLACE statements both specify sut_insert in the IN clause.

IN your examples above remove both the SELECT and the USE code - you don't need it.



how to use many remote views in one form???? Posted by Oxy- @ 10/5/2002 8:30:53 PM
RE: how to use many remote views in one form???? Posted by Jamie Osborn @ 10/6/2002 12:10:23 PM
RE: how to use many remote views in one form???? Posted by Oxy- @ 10/7/2002 10:14:02 AM