Normal Topic Subform shadow in TableView (Read 1141 times)
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Subform shadow in TableView
Mar 9th, 2009 at 6:50pm
Print Post Print Post  
In my Purch form, I have a subform POLines (a form of the POLines.db) .  I want to add and manipulate data entry in this subform in Form View.  But I would like to have a shadow subform (TVLines, which is also a form of the POLines.db) in tableview that only includes 5 fields of the POLines (ItemNum, ItemQty, ItemCost, ItemAvail, and ItemPlaced), so that the user can input/edit data in the Formview and have a nice summary in the TVLines subform of his progress on this PO.

I can get the TVLines subform to mirror the data in the POLines subform, but it won't hold the accumulated records as they are added in the POLines form.

Here is a screenshot of what happens ... http://www.wordcom.com/POscreen8.htm ; (I supplied the text "blank" in two of the columns of the TVLines to indicate that these fields were blank)

And here is the code in POLines that adds a new record in POLines, and that I'm trying to have add a new record then in TVLines.

"AddNewLineItem":: On Element Entry

var vTemp as Int //this button will save the current LineItem record and then add a new record
var vTV as Int
var vItemNum as string
var vItemQty as double
var vItemCost as money
var vItemAvail as string
var vPlaced as boolean

//      vItemNum = ItemNum
//      vItemQty = ItemQty
//      vItemCost = ItemCost
//      vItemAvail = ItemAvail
//      vPlaced = POLinesYN

     If (@Mode() = 0) Or (@Mode() = 1)
           {
              vItemNum = @FormFieldValue("POLines","ItemNum", 0)
                vItemQty = @FormFieldValue("POLines","ItemQty", 0)
              vItemCost = @FormFieldValue("POLines","ItemCost", 0)
              vItemAvail = @FormFieldValue("POLines","ItemAvail", 0)
              vPlaced = @FormFieldValue("POLines","POLinesYN", 0)
              FORMFIELDVALUE("TVPOLines","TVPOItemNum", 0, vItemNum)
              FORMFIELDVALUE("TVPOLines","TVPOItemQty", 0, vItemQty)
                FORMFIELDVALUE("TVPOLines","TVPOItemCost", 0, vItemCost)
              FORMFIELDVALUE("TVPOLines","TVPOItemAvail", 0, vItemAvail)
              FORMFIELDVALUE("TVPOLines","TVPOLinesYN", 0, vPlaced)
              FormCommit("TVPOLines")
              vTemp = @CreateNewRecord()
              vTV = @FormNewRecord("TVPOLines")            
              ThrowFocus(ItemNum)
           }



Suggestions?  
« Last Edit: Mar 9th, 2009 at 8:50pm by lksseven »  

Larry
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Subform shadow in TableView
Reply #1 - Mar 9th, 2009 at 9:39pm
Print Post Print Post  
Using a subform to provide a summary is pretty heavy, structurally. Why don't you show the summary with a multiline text editor instead? Much lighter and easier.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: Subform shadow in TableView
Reply #2 - Mar 9th, 2009 at 10:20pm
Print Post Print Post  
Oh!  Yes, I see how that would be much more elegant.  I'll tinker with that.  Thank you.
  

Larry
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: Subform shadow in TableView
Reply #3 - Mar 10th, 2009 at 3:05am
Print Post Print Post  
Here's what I came up with - it works!  But I'll gladly take suggestions on how to improve it.  Many thanks, Hammer.

AddNewLineItem:: On Element Entry

var vTemp as Int
var vLine as String
var vItemNum as String
var vItemQty as String
var vItemUoM as String
var vItemDesc as String
var vSumView1 as String

vItemNum = ItemNum
vItemQty = ItemQty
vItemUoM = ItemUoM
vItemDesc = ItemDesc


     If (@Mode() = 0) or (@Mode() = 1)
           
           {  // add a string array line to SummaryView1, create a new POLines record, throwFocus(ItemNum)
              vLine = vItemNum + " ** " +  vItemQty + " " + vItemUoM + " ** " +  vItemDesc + @Newline() + "==========" + @Newline()
              vSumView1 = @FormFieldValue("Purch", "SummaryView1", 0)
              vSumView1 = @AppendStringArray(vSumView1, vLine)
              FormFieldValue("Purch", "SummaryView1", 0, vSumView1)
              //WriteLn(vLine)
              vTemp = @CreateNewRecord()
              ThrowFocus(ItemNum)
           }
  

Larry
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Subform shadow in TableView
Reply #4 - Mar 10th, 2009 at 3:34am
Print Post Print Post  
Maybe I missed something, but just make a second form with ReadOnly fields you want bound to the fields in the POLines database.  Not need to do any programming.  It is using the data already in the database, just showing fewer fields.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Subform shadow in TableView
Reply #5 - Mar 10th, 2009 at 11:40am
Print Post Print Post  
Bob_Hansen wrote on Mar 10th, 2009 at 3:34am:
Maybe I missed something, but just make a second form with ReadOnly fields you want bound to the fields in the POLines database.  Not need to do any programming.  It is using the data already in the database, just showing fewer fields.

Since he wants it on the same parent at the same time, synching issues can present. Text is the safer choice in this case.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: Subform shadow in TableView
Reply #6 - Mar 10th, 2009 at 2:22pm
Print Post Print Post  
Bob,

a second read-only form was my initial thought and attempt, too.  But when I added a new record to the POLines primary subform, the 'shadow' tableview form would also add another line, but it wasn't retaining the data from the first record.

I actually placed two multiline fields on the parent form.  For us, PO's are a two step process - Step 1 - we build and save the po's multiple times during the day as we accumulate sales orders and determine our reorder needs - these line items are appended to the SumViewToBeOrdered multiline field to give the user a quick overview of the items that are on the dock to be ordered on that PO.

Then step 2 - is when we call in the vendors and place the orders.  As each line item is 'placed' with the vendor, the line just placed will be appended to SumViewOrdered.  At the same time, I'm going to try and have that line item deleted from the SumViewToBeOrdered field, so that the effect will be like pouring water from one glass to another glass.  When the PO's completely ordered, the SumViewToBeOrdered should be empty, and the SumViewOrdered should provide a quick visual reference of all the items ordered on that PO, without having to look at a tableview or print the PO.   

As I say, I'm happy to take advice on improvements/more efficient/elegant solutions! 
(some of my clumsy initial constructs are good programming exercises, though.  I learned a couple of - for me - hard concepts this weekend, thanks to the suggestions on this forum.  Many thanks!
  

Larry
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: Subform shadow in TableView
Reply #7 - Mar 11th, 2009 at 5:35pm
Print Post Print Post  
Main form "Purch" ... Subform "POLines" ... SummaryView is a text editor field on main form "Purch" ...

I'm having trouble building my SummaryView (text editor box) of PO line items placed.  The following code builds the summary view just fine, but after the 2nd line item is inserted, the programming throws the focus back to the first or second POLines record, instead of the 'next' record to be placed (3rd record, then 4th record, then ...) .  If I /* out this code, then the POLines programming works perfectly, taking me from the 1st record to the 2nd, then the 3rd, then the 4th, etc), but of course I don't get a summaryview field that's filled with line items ordered.

           vLine = vItemNum + " ** " +  vItemQty + " " + vItemUoM + " ** " +  vItemDesc + @Newline() + "==========" + @Newline()
           vSumView = @FormGetValues("Purch", "SummaryView")
           vSumView1 = vSumView + vLine
           vSumView = vSumView1
           FormFieldValue("Purch", "SummaryView", 0, vSumView)
           
           If ((@Mode() = 1) and (POLinesYN = 1) and (@FormViewType("") = 0))
           {
                 throwFocus(NextRecord1)
           }

The following code works great.  It is invoked as the PO is being built (but not 'placed' yet), line item by line item.  It plugs each line item into a SummaryView1 text editor field on PURCH that shows a list of items that have been entered into the PO, but not called in yet. 

     If (@Mode() = 0) or (@Mode() = 1)
           
           {  // add a string array line to SummaryView1, create a new POLines record, throwFocus(ItemNum)
              vLine = vItemNum + " ** " +  vItemQty + " " + vItemUoM + " ** " +  vItemDesc + @Newline() + "==========" + @Newline()
              vSumView1 = @FormFieldValue("Purch", "SummaryView1", 0)
              vSumView1 = @AppendStringArray(vSumView1, vLine)
              FormFieldValue("Purch", "SummaryView1", 0, vSumView1)
              //WriteLn(vLine)
              vTemp = @CreateNewRecord()
              ThrowFocus(ItemNum)
           }

I suspect the problem is that this code that works is always working on the 'sole' record that is being added, while the above above code that isn't working is throwing the focus back to the 1st record in the set.  My stumbling block is in not knowing how to tell the focus to go to the next record in the set that has not been placed yet (the next record in which the POLinesYN field is blank)
  

Larry
Back to top
IP Logged