Normal Topic sub form questions (Read 2031 times)
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
sub form questions
Feb 16th, 2008 at 5:47pm
Print Post Print Post  
I am having some confusion about subforms.  This is using versio 2.0.5 Sesame and Windows XP PRO SP2.

1.  We have a Purchase Order with a subform for LineItems.  We only want to add line items when in the Purchase Order.  So we want to use Add Records for creating Purchase orders but use Searchand Update Purchase Orders to add PO line Items.  When we do that on the subform does programming for the line item use @ADD or is it considered in Search Mode because it is part of the PO?

2.  What is the best way to stop adding Purchase Orders when pressing F10 in the Search and Update mode.  Only want to add PO in Add Mode.  But we do want to add Line Items in the PO Search Update mode by pressing F10 on the subform, but only want to add one record if some mandatory fields are filled in.  Right now, new records keep being added, both POs and LineItems.

3.  Tried to make a table view of the POs showing the line items but cannot do that so it sounds like i need to make the table view in the LineItems but need to know how a selection from that can open up the PO form that has that line item.  So, what is the best way to do this -- From a menu screen, click a button to open a Table View of all PO Line Items, only showing if Status=OPEN.  Then select one line item from the table and have the PO form open up for that line item so the PO record showing all the line items can be reviewed and edited?
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: sub form questions
Reply #1 - Feb 16th, 2008 at 7:02pm
Print Post Print Post  
obfusc88 wrote on Feb 16th, 2008 at 5:47pm:
1.  We have a Purchase Order with a subform for LineItems.  We only want to add line items when in the Purchase Order.  So we want to use Add Records for creating Purchase orders but use Searchand Update Purchase Orders to add PO line Items.  When we do that on the subform does programming for the line item use @ADD or is it considered in Search Mode because it is part of the PO?

The subform assumes the mode of the main form. So, even a new line item in the subform will be in Update mode if you are updating an existing main form.


Quote:
2.  What is the best way to stop adding Purchase Orders when pressing F10 in the Search and Update mode.  Only want to add PO in Add Mode.  But we do want to add Line Items in the PO Search Update mode by pressing F10 on the subform, but only want to add one record if some mandatory fields are filled in.  Right now, new records keep being added, both POs and LineItems.

Put this in the main form's On Form Entry event:
Code
Select All
// Prevent Extend Mode
FormNotifyForm(@Layout + ":(Update)", 7) 




Quote:
3.  Tried to make a table view of the POs showing the line items but cannot do that so it sounds like i need to make the table view in the LineItems but need to know how a selection from that can open up the PO form that has that line item.  So, what is the best way to do this -- From a menu screen, click a button to open a Table View of all PO Line Items, only showing if Status=OPEN.  Then select one line item from the table and have the PO form open up for that line item so the PO record showing all the line items can be reviewed and edited?

Yes, if I understand you correctly, this is how to handle it.
  


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


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: sub form questions
Reply #2 - Feb 17th, 2008 at 12:35am
Print Post Print Post  
Thanks you Carl Underwood for your answers. 

1.  So when Adding PO and then adding PO Lines, the PO lines are in Add Mode but they are in Update Mode when adding when the PO is in Update made.  I am not sure I understand why but i can follow the rules.

2.  I can put that code into the PO form but what do I put into the PO Lines to let me click down to add a new poline, but not let met click down three times and add three records?

3.  Ok so you agree how to do this.  but want i need is some code to show how to make that happen.  The PO Lines are on a subform on a PO tab.  So I need to see sample program for button to Open PO Line Form in Table view, only show records that have status=open, sorted by due date.  Then How do I select one of the lines and make the PO form open and got to the tab for the line items and go to the line item?  I cannot put a button on the table view, so what can i do to make the selcetion and run the code i need to see to do that?
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: sub form questions
Reply #3 - Feb 17th, 2008 at 2:59am
Print Post Print Post  
obfusc88 wrote on Feb 17th, 2008 at 12:35am:
2.  I can put that code into the PO form but what do I put into the PO Lines to let me click down to add a new poline, but not let met click down three times and add three records?

If you want to never allow more than two line items in the subform, then you could do it this way.
You would put this in the form's On Form Entry event and the On Element Immediate Change event:
Code
Select All
If @ResultSetTotal() = 2
	NotifyForm(7)
Else
	NotifyForm(-7) 




Quote:
3.  Ok so you agree how to do this.  but want i need is some code to show how to make that happen.  The PO Lines are on a subform on a PO tab.  So I need to see sample program for button to Open PO Line Form in Table view, only show records that have status=open, sorted by due date.  Then How do I select one of the lines and make the PO form open and got to the tab for the line items and go to the line item?  I cannot put a button on the table view, so what can i do to make the selcetion and run the code i need to see to do that?

I wouldn't open the "Line Form" (subform), but rather the main PO form in Table View. From there you could put focus on a line, and the click on the button (new in 2.0.5) at the top left corner of the corner of the Table View to bring you back to the Form View of the main form. Then you can add or edit the subform line items.

You would put this in a command button on the menu form:
Code
Select All
var n as int

ClientLocalValue("ShowOpenPOs", 1)
n = @SelectTreeItem(@Application + "!Forms!Search/Update!MyDB!MyForm") 



In the target form's On Retrieve Open Spec event:
Code
Select All
var n as int

// Resets the flag if previous run did not find any records to retrieve and left a flag set,
// because the flag normally doesn't get reset until the "On Form Entry" event.
If @ClientLocalValue("ShowOpenPOs") = 2 then ClientLocalValue("ShowOpenPOs", 0)

If @ClientLocalValue("ShowOpenPOs") = 1
{
	ClientLocalValue("ShowOpenPOs", 2)
	n = @LoadRetrieveSpec("MyRetrieveSpec")
	n = @LoadSortSpec("MySortSpec")
	n = @SelectTreeItem("Search Menu!Search Commands!Retrieve New Results (F10)")
} 



In the form's On Form Entry event:
Code
Select All
var n as int

If @ClientLocalValue("ShowOpenPOs") = 2 and @Update
{
	ClientLocalValue("ShowOpenPOs", 0)
	n = @SelectTreeItem("Search Update Menu!Other Commands!Toggle Table View (Shift-F6)")
} 


You'll need to create and save some retrieve and sort specs for use with this, then replace "MyRetrieveSpes" and "MySortSpecs" with the names you saved them as.

  


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


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: sub form questions
Reply #4 - Feb 17th, 2008 at 4:04am
Print Post Print Post  
This is a big help. but I think I was not clear about the first view.  We just want to look at PO Line Items that are OPEN across all POs, and select a single line item from them in a table view.  And that selection would open up the tope main level PO in Form view for editing.      If we open up the main PO form like you said, we will only be able to see the line items for a single PO and need to press F10 to go to the next PO.  If we open up Line Items that is all we will see, for all POs.  But if we hit the button on the table view that would bring us back to the LineItems formview at the LineItem level, not at the subform level of the PO.  So, that will not work.   We want to go to the PO top level that woueld now include that selected line item and all other line items for that PO independent of the status, would see OPEN and CLOSED items.  I hopt that this makes more sense now?
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: sub form questions
Reply #5 - Feb 17th, 2008 at 4:50am
Print Post Print Post  
Well, you just need to modify the code I showed above, to open the subform db (in standalone mode) rather than the main form db. From there, after selecting a line item, you can switch from Table View back to the Form View. Then, have a command button on that form containing code to get you to the main form using the basic techniques above. Use ClientLocalValue to store a record ID (or key) of some sort, that you would use as a retrieve spec to find the correct main form.

Alternatively, you might have a field in the 'line item' form that, when a certain value is present, would trigger code to open the main form.
  


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