Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Numeric fields in SQL vs VFP
Message
 
 
To
02/04/2010 16:47:23
General information
Forum:
Microsoft SQL Server
Category:
Database design
Environment versions
SQL Server:
SQL Server 2005
Application:
Desktop
Miscellaneous
Thread ID:
01458467
Message ID:
01458564
Views:
26
You can get type of the ControlSource using

type(thisform.text.ControlSource) && note, no quotes

However, this may not be always accurate (say, you would not be able to distinguish between memo and char or Integer and Numeric this way).

I'm thinking using afields may be a better way, though a bit complex, I agree.

>Thank you Naomi.
>
>At this point I am trying to figure out an efficient way to find the type of the control source of the field. The only way I know how to do it is to create an array using AFILED() and search for the particular field in the array for the size. But I am really hoping for something better. I guess, I can create a number of form array properties for each table I need to find the field type. Then in the gotfocus() of the textbox search for the type in the corresponding array and set the format accordingly.
>
>But I was hoping for something less "dramatic".
>
>
>
>
>
>
>>What about automatically setting picture to
>>replicate('9' * N-2) + . + replicate('9',M) where N is the total width and M is the decimal part?
>>
>>Just an idea.
>>
>>>Sergey,
>>>How do you go about automating a "picture clause" for all textboxes effected.
>>>
>>>Thank you in advance
>>>Yelena
>>>
>>>>VFP stores numeric data as a string. It has a few side effects
>>>>- A space has to be reserved for minus sign and a dot
>>>>- A numeric(10,2) field can store a value up to 10^10 by discarding a decimal part
>>>>
>>>>As I see it, you have 2 choices
>>>>- Add a picture clause to all textboxes affected by this
>>>>- Change size of the columns on backend
>>>>
>>>>Neither has to be done manually.
>>>>
>>>>
>>>>>I am converting an application from VFP as data and VFP as UI to SQL/VFP as a database and VFP as a front end.
>>>>>I did not notice it right away, but numeric type in SQL server is slightly different then in VFP.
>>>>>In SQL server, if I setup type of a field to be numeric(10,2), it means that it will allow 10 digits total, 2 of which will be after decimal point.
>>>>>I do not have to provide an additional digit for the "-" sign or for the decimal point. In VFP - 10 characters total, 2 digits after decimal point, but it will include decimal point and a "-" sign if negative number is used as part of the 10 characters.
>>>>>
>>>>>I also have noticed that if I use SPT or even a stored procedure to bring the data from the server, the numeric field type will change. So my numeric(10,2) field will become numeric(12,2). Which is great, but .... my users now can enter a bigger number then the data structure allowed. When saving the entered data to the server they will receive an error. Most of my numeric fields on the form depend on the control source, to control the size of the data entered into it. There would be too many objects on the screen to enter an input mask individually. Did anyone has this issue? Any suggestions?
>>>>>
>>>>>Thank you
>>>>>Yelena
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform