Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Scatter name causing data type mismatch
Message
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00525812
Message ID:
00525829
Views:
16
This message has been marked as the solution to the initial question of the thread.
David,

It's bad idea to give the object you create the same name as a table. Consider this code
lcCode = Product.Code
Is Product.Code a field in product table or property of the Product object? You'll have to use m.Product.Code to make sure that you reference a property.

To make it work create a property of the form named oProduct to save refrence to the object you create
Scatter Name loProduct
Thisform.oProduct = loProduct
Set conrolsource of your textboxes to the corresponding fields of Thisfom.oProduct in development or in the form Load
Thisform.txtCode = Thisform.oProduct.Code
Txproduct = Thisform.oProduct.Product
Txtprice  = Thisform.oProduct.Price
Make sure that Scatter is executed in the Load of the form for a first viewed record otherwise you'll get error in textboxes ititialization.

HTH

>I previously used the scatter memvar command, which worked, but all variables were public, so now I am experimenting with the Scatter Name oObject command.
>
>I have a sample test form with a page frame on it. On one page I have a grid and above that a few textboxes. In the data environment of the form I have a table called Product.
>
>I want to scatter the fields from this table into textboxes so that they can be viewed & edited (if necessary). I then want to gather the info from these textboxes.
>
>In the afterrowcolchange event of the grid I have placed a Scatter Name Product
> Command (to create an object of the same name as the table). The grid control source is set to Product (which is a table product.dbf)
>
>I have a few text boxes such as txtCode (Control source: m.code) and txproduct (m.product)
>Txtprice (m.price) and a few other fields.
>
>I keep getting a data type mismatch when I run the form and click in the grid (scatter name Product)
>
>I see in the local window of the debugger that some of these fields are shown there after clicking on the page (due to the blank textboxes). (I have also set the value of fields such as Price to zero, because they were showing up as character)
>Name: Value: Type:
>Code "" C
>Product "" C
>Price 0 N
>
>Then when I click on the grid (and Scatter Name Product) I get the Data Type Mismatch error. The textboxes on the form remain blank. I can then however see the object(Product) in the Local debugger window with a + sign. Expanding this shows me all of the tables fields, correctly filled with data from the record I tried to click on. However these object fields are not being scattered into the textboxes.
>
>Any help would be appreciated.
>
>Regards
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform