Hey guys,
I have a silly problem...  I'm trying to get the value of the field BEFORE I change it.  I thought that enterInField might work but then read about it.  Nope.  Barking up the wrong tree.  The user won't always select the field with a mouse but might stumble into the field after changing another field and hitting the ENTER key.
What I am trying to do is to create a changeLog so when someone changes the field's value (by any means) it will store the before and after value in a DB.
Any thoughts...?
Thanks
Paul
			
			
									
									
						Get field value before updating it
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Get field value before updating it
Hi Paul,
maybe "openfield" is what you are looking for?
Best
Klaus
			
			
									
									
						maybe "openfield" is what you are looking for?
Best
Klaus
Re: Get field value before updating it
Hey Klaus,
I do use that as well as focusIn. I've updated to 4.5 (dp3) and now for some odd reason it works! <smacks head>
It could have been a minor glitch in dp1 that was fixed in dp3..? I was going nuts. I have it as a behavior as I have quite a few fields that access the same code.
Thanks!
Hope to see you at RevCon 2011
Paul
			
			
									
									
						I do use that as well as focusIn. I've updated to 4.5 (dp3) and now for some odd reason it works! <smacks head>
It could have been a minor glitch in dp1 that was fixed in dp3..? I was going nuts. I have it as a behavior as I have quite a few fields that access the same code.
Code: Select all
on openField
   set the oldValue of this stack to me
   answer me  --see if it does grab the value
end openFieldCode: Select all
on focusIn
   set the oldValue of this stack to me
end focusInHope to see you at RevCon 2011
Paul
Re: Get field value before updating it
Nope.  I AM going nuts.  When I try it out on a single field it works fine.  It will store the old value and the new value.  When I hit ENTER and go to the next field, I only get the new value in the table.
I'm doing something wrong... I know this. But what and where...?
Does anyone see something glaringly simple that I keep tripping over..?
			
			
									
									
						I'm doing something wrong... I know this. But what and where...?
Code: Select all
on closeField
   createAuditTrail
end closeFieldCode: Select all
on openField
  --this works
   put me into fld "oldValue"
end openFieldCode: Select all
on focusIn
   openField
end focusInCode: Select all
on createAuditTrail
   put empty into changeData
   put "kasinstrux" into changeData["theTable"]
   put word 2 of (the effective name of me) into changeData["theField"]
   put fld "oldValue" into changeData["oldValue"]
   put fld "Broker" into changeData["PrimaryValue"]
   put "BankSym" into changeData["PrimaryKey"]
   put "Curr" into changeData["SecondaryKey"]
   put fld "Curr" into changeData["SecondaryValue"]   
   put me into changeData["NewValue"]
   updateChangeLog changeData  --basic insert query used
   put word 2 of (the effective name of me) into theField
   replace quote with empty in theField
   put quoteIt(titleCase(me)) into theValue
   --update the DB with the change made
   updateKASInstrux theField,theValue,fld "Curr",fld "Broker"
end createAuditTrail