Normal Topic close a subform but leave the Parent record open? (Read 570 times)
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
close a subform but leave the Parent record open?
Mar 15th, 2012 at 8:57pm
Print Post Print Post  
Is there a way to close a subform record while leaving a open the Parent record?

My Orders form has two subforms of the same database - SOLines (form view) and SOLTV (table view).  Tableview is visible upon Order form entry.  When I want to add or delete line items to that Order form, a command button on Orders form makes SOLTV subform invisible, and SOLines subform visible so I can add/delete line items.

My problem is that if I need to delete a line item from the SOLines database, the line item record is locked because the tableview subform SOLTV is still open, just not visible, so my 'delete' programming won't delete the line item completely.

FormExit won't work on subforms of open parents or on the focused form.  I tried setting up a menu tree string [(n = @SelectTreeItem("WordCom-BBC!Forms!Search/Update!Orders!SOLTV!Search Update Menu!Navigation!Close Form Without Saving (Esc)")]  in a "Close" field on SOLTV (was going to call it with RunFormProgram on the parent form), but I can't get the sequence right.   And I switched to Menu Tree mode so I could learn from doing it manually, and that's when I discovered that the "Close Form Without Saving (Esc)" menu selection won't work on a subform in the Parent Form view.


Any suggestions?
  

Larry
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: close a subform but leave the Parent record open?
Reply #1 - Mar 15th, 2012 at 10:34pm
Print Post Print Post  
I wrote an application for a client about 4 years ago, in which I start the subform as table view, and have a button that switches it to a read-only form view. The button is located on the subform itself, and contains this:
Code
Select All
FormViewType("", 1)
@Msg("==========  SUBFORM is read-only when in table view  ==========") 



If you use that idea, you will also need code similar to this in the [MySubformNameHere] :: On Form Entry event, to make the LEs read-only.
Code
Select All
// Set or unset read-only status
If @FormViewType(sThisFormName) = 1	// Table view
or @Standalone() = 1			// Not Subform
{
	// Set read-only
	vElementList = @StringArrayElementList()
	// Remove some elements from list so they stay accessable
		vRemove = "PrevButton;NextButton;FirstButton;LastButton;F3Button;EscButton;F7Button;SimpleSearchButton;SaveButton;CommandArea;TableViewButton"
		vElementList = @DifferenceStringArray(vElementList, vRemove)
	n = @CountStringArray(vElementList)
	For i = 1 to n
		vElement = @AccessStringArray(vElementList, i)
		ReadOnly( @(vElement), 2)	// 0 = writable, 1 = read-only, 2 = read-only but not grayed
	Next
}
Else					// Form view
{
	// Unset read-only
	vElementList = @StringArrayElementList()
	// Remove some elements from list so they stay read-only
		vRemove = "MaterialCode;BOL;Date1;Warehouse;ShipmentType;RecordID;Shipped"
		vElementList = @DifferenceStringArray(vElementList, vRemove)
	n = @CountStringArray(vElementList)
	For i = 1 to n
		vElement = @AccessStringArray(vElementList, i)
		ReadOnly( @(vElement), 0)	// 0 = writable, 1 = read-only, 2 = read-only but not grayed
	Next
} 



Note that if you begin the subform as form view, you can switch to table view and back again. But, if you begin as table view, you cannot switch to form view.

I seem to remember first attempting your approach of having a form of each type, but soon ran into problems similar to what you described. And that's why I ended up going with this solution.
  


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



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: close a subform but leave the Parent record open?
Reply #2 - Mar 16th, 2012 at 2:42am
Print Post Print Post  
Hi Carl,

Thank you for your example and suggestions!

The sticking point for my situation is that I need to generate an invoice via PrintAFormToHTML, and PrintAFormToHTML will not WYSIWYG print a subform that began as a formview and  is then toggled to a tableview (it prints the first record of the subform in formview). 

Maybe I can get where I need to go by creating a separate Orders form (call it Invoice) and stick the SOLines Tableview (SOLTV) subform in it.  And generate invoices only from this form.  Would make it a lot less heavy lifting for Sesame for the invoicing process versus the way I'm currently doing it.  I was just hoping to avoid doing the redesign  Cry

It was NICE to have that tableview subform show up in update mode while scrolling through orders and see the entire order at a glance ... sigh.
  

Larry
Back to top
IP Logged