Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why is the views updated so slowly?
Message
From
27/03/2000 12:57:51
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00350821
Message ID:
00350831
Views:
22
>HI all,
>
>I am new to VFP, so please be patient. I have 2 remote views:
>1. order_view(PK:order_id, FK: city_id)
>2. loation_view(PK :location_id, location_id is the automatic number)
>I have used the order_view to designed a formset that includes 2 form (named Form1 & Form2).
>On Form1 I have a combo box for the users could select or enter the value. I set this combo box with:
> RowSourceType = 6-Fields
> RowSource = location_view.location_city, location_id
>On Form2 I used the Insert-SQL to insert fields to location_view.The coding as following:
>
>Insert into location_view(lo_address
>                          lo_city,;
>                          lo_state,;
>                          lo_zip,;
>                          lo_country);
>       values(Thisformset.Form2.txtAddress.value,;
>                  Thisformset.Form2.txtCity.value,;
>                  Thisformset.Form2.cboState.value,;
>                  Thisformset.Form2.txtZip.value,;
>                  Thisformset.Form2.txtCountry.value)
>   Messagebox("The New Co-location is added into the databes",;
>                        48, "Addition Message")

You're putting an immense amount of unneeded ovcerhead in this just resolving the objuect refs;  try:

WITH Thisformset.form2
 Insert into location_view(lo_address
                           lo_city,;
                           lo_state,;
                           lo_zip,;
                           lo_country);
        values(.txtAddress.value,;
               .txtCity.value,;
               .cboState.value,;
               .txtZip.value,;
               .txtCountry.value)
ENDWITH
>When the users enter a new location_city that doen't exist in combo box, they need to add this new. They go to Form2 to add the new location then come back Form1. At this time, they drop down the combo box the location_city and location_id should be in there already. The problem is the location_id in combo at this time is 0 always. Now, the location_id (automatic number) just returns to correct value if the user exist either this form and log off the application then log in application and run form again. I want the location_id in combobox would be correct value when the users go back Form1.

You have to force the change through to the base table using TABLEUPDATE(), the content of the combobox won't be changed with the new values until you requery to refresh the ComboBox's list of values from RowSource. The following is cut straight from the VFP docs:
Requery Method

Requeries the row source to which the ListBox or ComboBox control is bound.

Syntax

Control.Requery

Remarks

Use the Requery method to ensure a control contains the most recent data. The Requery method requeries the RowSource property and updates the list with the new values.
You could then assign the .Value to the correct (or rely on the referesh of the ControlSource for the ComboBox). IOW, the list doesn't change just because the potential set of values backing the list cfhanges, and the value doesn't change unless the ControlSource is changed to a valid value for the list...
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform