Select to view content in your preferred language

Problem with setting values

604
2
01-31-2011 05:35 AM
PeterBold
Emerging Contributor
Hi,

I use a custom edit-form. It is possible that some controls become invisible during the user enters data. If this happens, I want the script to set the values of these controls to zero.

Here is my idea:

Sub CheckFeatureValues
 Dim thisPage
 Set thisPage = Map.Layers("A").Forms("EDITFORM").Pages("A")
 If Not thisPage.Controls("txtWidth").Visible Then
  thisPage.Controls("txtWidth").Value = ""
 End If
End Sub


I call this sub when the OnValidate-Event of the Form-Page "A" is fired. If I check the value of the control with a MsgBox ("MsgBox thisPage.Controls("txtWidth").Value"), the value is correctly set to "". But in spite of that the OLD value of the control is saved to the database.

Any ideas why this happens and how to solve it?

Thanks for your help.

Peter
Tags (3)
0 Kudos
2 Replies
RolfBroch
Frequent Contributor
I do not know if this could be the problem but you can only set values for controls on a page that is active. If Map.Layers("A").Forms("EDITFORM").Pages("A")
is not active, the result of the thisPage.Controls("txtWidth").Value = "" is not reliable.

Rolf
0 Kudos
PeterBold
Emerging Contributor
Thanks for your answer. I don't think that this was the problem, because when I tested this, the page was active.

I solved this by setting the values to zero whenever I set the control to "invisible". That works.

Peter
0 Kudos