Normal Topic Setting Retrieve Specs via Programming (Read 3843 times)
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Setting Retrieve Specs via Programming
Mar 22nd, 2022 at 3:56am
Print Post Print Post  
I've used code similar to the following in the "On Retrieve Spec Open" event for years:
FormFieldValue("Main Form", "Date_entered", 1, "=")

That works great on the main form. I now have a need to do this with subforms, but it doesn't work on subforms.

I can read a value from a subform with @FormFieldValue, but cannot set a value there with FormFieldValue. Here's the actual code I'm using to test with:
Code
Select All
var vStr as String

vStr = @LoadRetrieveSpec("Temp")
WriteLn(@FormFieldValue("Checkbook Transactions", "Note", 0))

FormFieldValue("Checkbook Transactions", "Note", 0, "TEST")
WriteLn(@FormFieldValue("Checkbook Transactions", "Note", 0)) 


For testing purposes, the I'm using the "Temp" retrieve spec to put something in the subform Note field, so that I have something to read when @FormFieldValue reads it. That gets displayed in the WriteLn slate. - Works great.
But, when FormFieldValue attempts to set a new value in the subform Note field, and again, @FormFieldValue reads the Note field, it displays the same thing as the first read.

I'm hoping Ray has a solution. Wink
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
cbislander
Full Member
***
Offline



Posts: 107
Joined: Mar 22nd, 2018
Re: Setting Retrieve Specs via Programming
Reply #1 - Mar 22nd, 2022 at 12:06pm
Print Post Print Post  
Shouldn't it be

Var vStr as Int ?
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Setting Retrieve Specs via Programming
Reply #2 - Mar 22nd, 2022 at 1:06pm
Print Post Print Post  
cbislander wrote on Mar 22nd, 2022 at 12:06pm:
Shouldn't it be

Var vStr as Int ?
                   

Technically, @LoadRetrieveSpec does return Int, but a String can still receive it. So, it has no bearing on the fact that FormFieldValue fails to populate the subform field.

I normally do use Int like this:
var vNav as Int
vNav = @LoadRetrieveSpec("Recalculate Balance")

But in this case, this was just a test, and I'm not using the value returned from @LoadRetrieveSpec, or testing it for an error, so it doesn't really matter.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Setting Retrieve Specs via Programming
Reply #3 - Mar 22nd, 2022 at 2:06pm
Print Post Print Post  
Hey Carl,

For a subform, I believe you need to use 1 for the record number at the retrieve spec.

Ex:
Code
Select All
FormFieldValue("Gems", "Gem", 1, "A..") 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Setting Retrieve Specs via Programming
Reply #4 - Mar 22nd, 2022 at 2:15pm
Print Post Print Post  
I think I know what is going on. Table View subform? You need to use a 1. Form View you can use either a 0 or a 1.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Setting Retrieve Specs via Programming
Reply #5 - Mar 22nd, 2022 at 8:07pm
Print Post Print Post  
Ray the Reaper wrote on Mar 22nd, 2022 at 2:15pm:
I think I know what is going on. Table View subform? You need to use a 1. Form View you can use either a 0 or a 1.

-Ray

Interesting issue here. I'm finding that, for subforms, @FormFieldValue must use a "0", and FormFieldValue must use a "1" for them to work. I think this is what tripped me up during my testing. Foolish me. Wink I assumed that if a zero worked with @FormFieldValue, then logically it would also work with FormFieldValue.

But, there is another reason why I couldn't get it working. This table-view subform is on the 2nd tab of a tabpage group, so it isn't in view when first entering Search mode. If I move this subform to the 1st tab position, it does work. Undecided

I don't want change the layout of those tabs, so I decided to try using GotoTabPage(TabGroup, 3) just before FormFieldValue to see that would get it to work. And it did! Yay! Smiley

Thanks Ray!
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Setting Retrieve Specs via Programming
Reply #6 - Mar 23rd, 2022 at 2:05pm
Print Post Print Post  
Carl Underwood wrote on Mar 22nd, 2022 at 8:07pm:
But, there is another reason why I couldn't get it working. This table-view subform is on the 2nd tab of a tabpage group, so it isn't in view when first entering Search mode. If I move this subform to the 1st tab position, it does work. Undecided


Hey Carl,

You may have had something else going on as I made the Gems subform table view and threw it on the 3rd tab in a group and the code still worked just fine, from a button on the parent form or the On Retrieve Spec open event of the Parent Gem Types form. But as long as it's working for you now, awesome. 

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Setting Retrieve Specs via Programming
Reply #7 - Mar 23rd, 2022 at 10:13pm
Print Post Print Post  
Ray,

You're correct. There's some sort of corruption. There are 2 table-view subforms on that same tab. One of them works without forcing the tab to display before attempting to set the value, and the other one works either way.

To test the corruption theory, I exported the design to XML, imported it to a new test app, and it works properly in that new app. (PS: This XML process is flawed though, because many labels display as "Widget Defaults". I can remove it from most, but I cannot remove it from the tab page element.)
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Setting Retrieve Specs via Programming
Reply #8 - Mar 24th, 2022 at 1:43pm
Print Post Print Post  
Carl,

Send me the app as that's not something I have ever seen before.

As for the Widget Defaults, you can do a Search/Replace in the XML file to get rid of them.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Setting Retrieve Specs via Programming
Reply #9 - Mar 29th, 2022 at 12:37am
Print Post Print Post  
Ray the Reaper wrote on Mar 24th, 2022 at 1:43pm:
Send me the app as that's not something I have ever seen before.

Sorry, I've already fixed the corruption. It now works fine, without the need for GotoTabPage.

For the benefit of others that may need to do the same, here's how I did it:
I exported the individual subform layout to XML, deleted the original subform layout (not the database, just the layout), imported the XML using "Import XML Form", and renamed the newly imported layout to the same name as the original. Then, I recreated the subform layout element in the parent layout, being careful to select the option to "Show existing Natural Child records: [MySubrecordFieldName]" where it asks "Select records to display".

On a side note about XML:
There's a bug in Sesame with the "Application > Export Programming" in Designer. It does NOT export Global Code from reports, nor does is export Mass Update code.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged