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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unexpected control value

Status
Not open for further replies.

Russ1005

Programmer
Dec 13, 2004
96
US
In VFP 7, I have the following spinner control with an initial value of 31. When I change the value manually to a different number say 25 and access the value property of the control in the Save button click event, the value still shows 31.

THISFORM.BCPageFrame1.Page1.SPnBillDayNbr

Any idea what is causing this behavior?

Thanks.
 
I cannot duplicate this situation. Here is what I tried.
Code:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form


	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT spinner1 AS spinner WITH ;
		Height = 24, ;
		Left = 120, ;
		Top = 48, ;
		Width = 121, ;
		Value = 31, ;
		Name = "Spinner1"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 132, ;
		Left = 204, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command1"


	PROCEDURE command1.Click
		MESSAGEBOX(transf(thisform.spinner1.Value ))
	ENDPROC


ENDDEFINE


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
No, that doesn't make sense. I trust you are running VFP 7 SP1? What happens when you execute this code, does it work as expected?
Code:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form

	AutoCenter = .T.
	DoCreate = .T.
	Caption = "Spinner Value Test"
	Name = "Form1"


	ADD OBJECT command1 AS commandbutton WITH ;
		AutoSize = .T., ;
		Top = 180, ;
		Left = 132, ;
		Height = 27, ;
		Width = 95, ;
		Caption = "Spinner Value", ;
		Name = "Command1"


	ADD OBJECT spinner1 AS spinner WITH ;
		Height = 24, ;
		Left = 144, ;
		Top = 48, ;
		Width = 84, ;
		Name = "Spinner1"


	PROCEDURE command1.Click
		MESSAGEBOX(TRANSFORM(this.Parent.spinner1.Value), 64, "Spinner's Current Value")
	ENDPROC


ENDDEFINE

...even when it's contained in a page of a pageframe it should work fine.

boyd.gif

SweetPotato Software Website
My Blog
 
THanks for you quick response. Do you think it has something to do with the control source pointing to the original value in the table?
 
Yes, it is SP1. The above code works fine so it must be something quirky going on.
 
LOL... well Mike, I guess I need to refresh the thread before posting next time.

Russ1005,
Glad to hear the code works. Not that it helps, but I've never heard of this bug, I can't reproduce it in VFP7 SP1 no matter what I do (controlsource or no controlsource). I'll definitely be watching this thread, cause I'd really like to know how you ended up with this behavior.

boyd.gif

SweetPotato Software Website
My Blog
 
I put the following code in the interactivechange event for the spinner and that took care of it though I'm not sure why it was necessary to do this.

THISFORM.BCPageFrame1.Page1.SPnBillDayNbr.Value = VAL(THISFORM.BCPageFrame1.Page1.SPnBillDayNbr.Text)
 
Craig said:
LOL... well Mike, I guess I need to refresh the thread before posting next time.

Interesting that the code is almost 100% the same...same techniques of quick testing.:)




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Is the Save button in a toolbar? I suspect this is a timing issue.

Tamar
 
Mike,
Great minds think alike!

Tamar,
Interesting point Tamar, since the toolbar wouldn't cause the valid event to fire (and thus transfer the displayed value) for the spinner because focus isn't lost? Wish I had thought of that. I guess some great minds think differently.

boyd.gif

SweetPotato Software Website
My Blog
 
No the save button is not in the toolbar. The code in the interactivechange event did the trick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top