Jim Harvey wrote:
> I'd like to update a field value by allowing the user to click a button that
> has a value as it's caption.
>
> There will be multiple buttons each with its own distinct value.
>
> I can put code in the click of each button knowing it's assigned value, and
> that will do the job, but would rather use a form method.
>
> Is there a way to have the method determine which button was clicked, and
> therefore assign the new value to the field.
>
> The code I'm using now in the button.click is:
>
> SELECT bidboard
>
> UPDATE bidboard SET amount = 6000
>
> llok = tableupdate(1,.f.,'bidboard')
>
> thisform.refresh
If I'm following you correctly, I would create a form method MyMethod
with a parameter. In the button click, I'd either call
Thisform.MyMethod(1) (Where the numeric is different for each button),
or better yet ThisForm.MyMethod(this.name) (allowing for exactly the
same code in each button)
Then in the method, use a CASE statement, and proceed from there.
I'd like to update a field value by allowing the user to click a button that
has a value as it's caption.
There will be multiple buttons each with its own distinct value.
I can put code in the click of each button knowing it's assigned value, and
that will do the job, but would rather use a form method.
Is there a way to have the method determine which button was clicked, and
therefore assign the new value to the field.
The code I'm using now in the button.click is:
SELECT bidboard
UPDATE bidboard SET amount = 6000
llok = tableupdate(1,.f.,'bidboard')
thisform.refresh
James E Harvey
Hanover Shoe Farms, Inc.
M.I.S./Corresponding Officer
Off: 717-637-8931
fax: 717-637-6766
email: jharvey@hanoverpa.com
On Thu, Mar 26, 2009 at 1:22 PM, Jim Harvey <jharvey@hanoverpa.com> wrote:
> I'd like to update a field value by allowing the user to click a button that
> has a value as it's caption.
>
> There will be multiple buttons each with its own distinct value.
>
> I can put code in the click of each button knowing it's assigned value, and
> that will do the job, but would rather use a form method.
>
> Is there a way to have the method determine which button was clicked, and
> therefore assign the new value to the field.
>
> The code I'm using now in the button.click is:
>
> SELECT bidboard
>
> UPDATE bidboard SET amount = 6000
>
> llok = tableupdate(1,.f.,'bidboard')
>
> thisform.refresh
-----------------------------
just a guess here:
Click event for each button calls a single method with a param that
states the button.text
You can then use a CASE to separate the code that is unique to the button.
HTH
--
Stephen Russell
Sr. Production Systems Programmer
Web and Windows Development
Independent Contractor
Memphis TN
901.246-0159
Author: MB Software Solutions General Account
Posted: 2009-03-26 14:55:28 Link
Vince Teachout wrote:
> Jim Harvey wrote:
>> I'd like to update a field value by allowing the user to click a button
that
>> has a value as it's caption.
>>
>> There will be multiple buttons each with its own distinct value.
>>
>> I can put code in the click of each button knowing it's assigned value,
and
>> that will do the job, but would rather use a form method.
>>
>> Is there a way to have the method determine which button was clicked, and
>> therefore assign the new value to the field.
>>
>> The code I'm using now in the button.click is:
>>
>> SELECT bidboard
>>
>> UPDATE bidboard SET amount = 6000
>>
>> llok = tableupdate(1,.f.,'bidboard')
>>
>> thisform.refresh
>
>
> If I'm following you correctly, I would create a form method MyMethod
> with a parameter. In the button click, I'd either call
> Thisform.MyMethod(1) (Where the numeric is different for each button),
> or better yet ThisForm.MyMethod(this.name) (allowing for exactly the
> same code in each button)
Vince -- you meant ThisForm.MyMethod(this) (...not just the name
attribute, but the actual object) right?
MB Software Solutions General Account wrote:
> Vince -- you meant ThisForm.MyMethod(this) (...not just the name
> attribute, but the actual object) right?
No, in my example (again, assuming I understood the question) only a
property that can be tested by a CASE statement needs to be passed.
So if the Button name was ButtVal1, the click method
Thisform.MyMethod(this.name) would send the parm "ButtVal1" to the
method, and a CASE would then process for ( CASE lMyParm = "ButtVal1" )
On Thu, Mar 26, 2009 at 12:29 PM, Vince Teachout <teachv@taconic.net> wrote:
> MB Software Solutions General Account wrote:
>
>
> > Vince -- you meant ThisForm.MyMethod(this) (...not just the name
> > attribute, but the actual object) right?
>
> No, in my example (again, assuming I understood the question) only a
> property that can be tested by a CASE statement needs to be passed.
>
> So if the Button name was ButtVal1, the click method
> Thisform.MyMethod(this.name) would send the parm "ButtVal1" to the
> method, and a CASE would then process for ( CASE lMyParm = "ButtVal1" )
>
>
>
>
>
>
>
> So why not pass "this"? You can then reference the button.Caption (or any
> other property) directly and not need any CASE statement.
>
>
> --
> Fred
>
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
Author: MB Software Solutions General Account
Posted: 2009-03-26 16:27:12 Link
Vince Teachout wrote:
> No, in my example (again, assuming I understood the question) only a
> property that can be tested by a CASE statement needs to be passed.
>
> So if the Button name was ButtVal1, the click method
> Thisform.MyMethod(this.name) would send the parm "ButtVal1" to the
> method, and a CASE would then process for ( CASE lMyParm = "ButtVal1" )
Oh...I thought you meant that they were similar objects and hence had
the same interface, so referring to the common object was the way.
Author: MB Software Solutions General Account
Posted: 2009-03-26 16:27:20 Link
Fred Taylor wrote:
>> So why not pass "this"? You can then reference the button.Caption (or any
>> other property) directly and not need any CASE statement.
>>
>>
>> --
>> Fred
My point exactly.
Fred Taylor wrote:
> On Thu, Mar 26, 2009 at 12:29 PM, Vince Teachout <teachv@taconic.net> wrote:
>
>>
>> So why not pass "this"? You can then reference the button.Caption (or any
>> other property) directly and not need any CASE statement.
In this example, how does it eliminate the need for CASE?
Again, assuming I am understanding the problem correctly (ie, "change a
value, depending on which button I pressed."), what's the difference
between:
CASE myParam = "button1"
and
CASE oMyParam.Name = "button1"
?
Going back to the original request:
>> I'd like to update a field value by allowing the user to click a button
that has a value as it's caption.
Would result with:
UPDATE bidboard SET amount = val(oButton.Caption)
-----Original Message-----
From: Vince Teachout
Sent: Thursday, March 26, 2009 4:30 PM
Fred Taylor wrote:
> On Thu, Mar 26, 2009 at 12:29 PM, Vince Teachout <teachv@taconic.net>
wrote:
>
>>
>> So why not pass "this"? You can then reference the button.Caption
>> (or any other property) directly and not need any CASE statement.
In this example, how does it eliminate the need for CASE?
Again, assuming I am understanding the problem correctly (ie, "change a
value, depending on which button I pressed."), what's the difference
between:
CASE myParam = "button1"
and
CASE oMyParam.Name = "button1"
?