Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flex set focus problem

Status
Not open for further replies.

vbajock

Programmer
Jun 8, 2001
1,921
US
Here's a weird one. I am writing Flex code to modify the UPC field in the IM maintenace screen. When I go to write the new UPC code to the screen, I get a "cannot update the field if it doesn't have the focus error" even though I am explicity setting the focus to macform.upc before attempting to write the new data. Here's the weird part - if I step thru the code one line at a time in the debugger, it works fine. Anyone got anything on this?
 
What field are you triggering the code from? Macola Flex has some draw-backs that are not well published or known about. I would guess that you are triggering the following code from a control where something else is happening by Macola or that the UPC Code has something running behind the scenes from Standard Macola.


Sub Somecontrol_Losefocus
UPCCode.setfocus
UPCCode.text = "Tek-Tips Is Great"
End Sub

This is tossing an error for me too when doing this from several controls on the first tab of the form.

This on the other hand works.

1. Declare a modular string variable
2. On the lose focus event of the control where you are calculating the contents of UPC CODE, fill the string with the value.
3. On the GotFocus event of the UPC Code set its .text property to = variable. i.e. upccode.text = mstString.

Andy

Andy Baldwin
 
Thanks - your suggestion worked. Apparently in Flex the commands

macform.somefield.setfocus
macform.somefield.text = "Whatever"

does not work.

You set the focus in one procedure, and the value of the field can only be changed when the actual Got_focus event for the field is fired in response to the Setfocus, and the value must be changed within that event. Thanks again Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top