Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Question
Message
From
20/10/1997 15:22:46
 
 
To
20/10/1997 15:18:31
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00055504
Message ID:
00055595
Views:
31
>>>>>>>>>Hello,
>>>>>>>>>
>>>>>>>>>I have a UDF called ConvToView that takes a value and converts it to a normal looking time. For Example, I store 5:00p in a table as 1700.
>>>>>>>>>
>>>>>>>>>My problem is I want a grid that has a column bound to this particular field but I need to run this UDF on it first. In other words I want 5:00p to show in the text box rather than 1700.
>>>>>>>>>
>>>>>>>>>I have tried to put in the ControlSource of the column ConvToView(ava_bgntime) but this doesn't work. I also tried to put the function call in the InterActiveChangeEvent of the text box in the column but this didn't work either. Any Ideas?
>>>>>>>>>
>>>>>>>>>Paul
>>>>>>>>
>>>>>>>>If you will set ColumnX.ControlSource to Thisform.ConvToView(table.time) in Form Designer, then it should work Ok, assuming that ConvToView is form method.
>>>>>>>
>>>>>>>ConvToView is a function in a separate prg file. The main reason for this is that I use this function in many forms.
>>>>>>
>>>>>>I think that it will work too, assuming that you Set Procedure to the prg file.
>>>>>
>>>>>I have set procedure to the prg file. Whats odd is that if I just leave the control source to the table fields the grid shows the records(except that the time field is just a number) but as soon as I put ConvToView(ava_bgntime) in the controls source of the second column then no records appear in the grid plus I do not get an error message.
>>>>>
>>>>>Weird, huh?
>>>>
>>>>Yes, it's weird. Is ava_bgntime field name? Did you try to add alias? Is it possible that you switched aliases in prg. I guess you should:
>>>>1. Test it with Form' method.
>>>>2. Test it adding new column on right.
>>>>I believe you will get right behaviour moving this way. The ultimate way to avoid controlsource problems is to set them for each column programmatically.
>>>
>>>I tried making ConvToView a method for the form and then I set the control source of column2 programatically and now I get an error that says "the data source for this object must be a variable reference" I clicked on help and it sounds like I am not allowed to use an expression for a control source. Does this make sense?
>>
>>No. You are allowed to use the expression like: "Thisform.ConvToView(table.time)". Surely, the method should return something back in proper data type.
>
>This is a quirk with the properties sheet. If you try to type in a function name in the controlsource space, it will give you this error. But if you use the expression builder to type it in, it will work. Same exact code, just putting it there in a different way.

And this quirk doesn't always happen. Sometimes, it's good enough to add "=". Sometimes, it works without problems at all, e.g. today, when I made quick test before posting the reply. It's really true to say, that good code is code which passed the test, and doesn't matter why it's looking so strange...
Edward Pikman
Independent Consultant
Previous
Reply
Map
View

Click here to load this message in the networking platform