Normal Topic Read only table view subform (Read 1489 times)
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Read only table view subform
Jun 27th, 2007 at 6:03pm
Print Post Print Post  
I have a table view subform  on a tab that I use to create a new subrecord. The jist of the programming section that handles this is like this:

nn = @FormNewRecord("payments")
FormFieldValue("payments", "transaction_date", nn, @date)
FormFieldValue("payments", "transactionType", nn, TempTransType)
FormFieldValue("payments", "paymentamount", nn, TempTransAmount)
FormFieldValue("payments", "Paymentdate", nn, TempPaymentDate)
FormFieldValue("payments", "Paymentchknum", nn,  TempchecknumDate)
FormFieldValue("payments", "TransactionNote", nn,  TemptransactionNote)
FormFieldValue("payments", "Billed amount", nn, "0")

I only want the user to be able to affect the table view subform (a basic payment and billing ledger) via my programmed fields so I set the subform element to read only. This works fine until more data is posted then the subform element size. In read only  I am not able to use the subform sizing arrow bar to scroll down.

Is there a way to allow the sizing arrows to be active even in read only?

One method that solves this problem is to leave the subform NOT read only and set the elements in the database the subform is made from to read only. This allows the scroll bars to work while protecting the element data with read only capabilities.

The problem with this method  is I was planning on having a manager feature that temporarily makes my subform Not read only so they could easily correct or manage the data from the subform. I know how to easily change the read only attribute of the subform with Sbasic, but I am not sure if my attribute commands will allow me to temporarily change attributes on a different form in a different database.

Any Thoughts?

Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Read only table view subform
Reply #1 - Jun 28th, 2007 at 12:06pm
Print Post Print Post  
Maybe you could check @Group in the subform's On Form Entry event where a loop cycles through all the subform elements, setting them to read-only or not, based on the the Group the user belongs to.

Here is a possible solution that you could put in the subform's On Form Entry event. This is untested, but may get you started.

Code
Select All
var n as int
var i as int
var vElementList as string
var vElement as string
var vReadOnly as int


if @Group = "Manager"
	vReadOnly = 0			// 0 = writable, 1 = read-only, 2 = read-only but not grayed
else
	vReadOnly = 2

vElementList = @StringArrayElementList()
n = @NumberOfElements()

For i = 1 to n
	vElement = @AccessStringArray(vElementList, i)
	ReadOnly( @(vElement), vReadOnly)
Next
 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
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: Read only table view subform
Reply #2 - Jun 28th, 2007 at 4:59pm
Print Post Print Post  
How about put all "Read Only" elements on same level (Version 2), then make that level ReadOnly vs. time to do loops?
  



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: Read only table view subform
Reply #3 - Jun 28th, 2007 at 6:30pm
Print Post Print Post  
Bob_Hansen wrote on Jun 28th, 2007 at 4:59pm:
How about put all "Read Only" elements on same level (Version 2), then make that level ReadOnly vs. time to do loops?


Using a layer would give you the list, but you would still have to touch each element in the list using a loop.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Alec
Lanticans
*****
Offline



Posts: 200
Location: Ascot, England, UK
Joined: Nov 22nd, 2002
Re: Read only table view subform
Reply #4 - Jul 1st, 2007 at 10:59pm
Print Post Print Post  
In a very recent Inside Sesame article jointly penned by Tom Marcellus and myself, we described this exact scenario. We reckon the way to do it is to make each subform element read-only and keep it that way, but provide buttons and 'mirror' elements on the parent form for manipulating the subform records as required. This way you can do whatever you want security-wise on the main form, provide unbound elements to show the data from a specific subrecord, and allow the user to edit that record or delete it. Oh and records can only be added this way too. The subform is visible only for convenience, to view multiple records. The subform can even be invisible, permanently and I have an app that does this. The article is "Managing Table View Subforms" in the May 2007 edition of Inside Sesame.
  

Alec
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Read only table view subform
Reply #5 - Jul 2nd, 2007 at 3:21pm
Print Post Print Post  
Thanks, for all the info and help Smiley
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Read only table view subform
Reply #6 - Jul 2nd, 2007 at 10:08pm
Print Post Print Post  
Alec and Toms Example in the Inside Sesame article was terrific. It works very well. I tried (but failed) cannibalizing the same code to do a similar task. Instead of modifying the data based on the users selection of the subform record I wanted to use some of the data in the subform with a MergeFilePrint() command.

My thought was when a print reminder command button was selected  I would present the user with a popup selection of the subform records and have them select what record in the subform would be used to grab the data to create the merge file.

My subform is made up of charges and payment transactions. The possible choices in transactiontype are:
Regular Charge
Late Charge
NOD Charge
Nod Late Charge
Insurance Charge
Other Charge
Regular Payment
Late Payment
NOD Payment
Nod Late Payment
Insurance Payment
Other Payment

The code below works great to ask the user to make a selection and then returns the correct data for me to use in my mergefileprint() however after playing with it I realized that the only choices the user should have on the popup selection should be charges. (it would be silly to remind them to pay a payment)

I have tried numerous methods to restrict the selection to only charges but I guess I do not have a good enough grasp on the workings of @FormFieldValue() and AppendStringArray() (at least this is the section I thought I need to modify)

Any suggestions on what or how I need to change this code?  Thanks




var n as Int
var vCount as Int
var vEdits as String
var vChoice as String

var vbilledAmount as String
var vtransactionId as String
var vChargememo as String




If @Mode() < 2
     {
           
vCount = @FormResultSetTotal("Payments")

     If vCount = 1 Then


                 If @FormFieldValue("Payments", "transactionType", 1) = "" Then
                 vCount = 0

                 For n = 1 to vCount


                 vEdits = @AppendStringArray(vEdits, "Print Reminder for Transaction# " + n)
//writeln(vedits)
                 Next

                 PopupSelectPosition(4, @XPos(ThisElement), @YPos(ThisElement))
                 vChoice = @PopupMenu("" + vEdits + ";"  ,"choose to print")
           
                 
                 
                 TempTransType = @FormFieldVAlue("payments", "Transactiontype", @Num(vChoice))
                 vbilledAmount = @FormFieldVAlue("payments", "billed Amount", @Num(vChoice))
                 vtransactionId = @FormFieldVAlue("payments", "TransactionId", @Num(vChoice))
                 //vChargememo = @FormFieldVAlue("payments", "ChargeMemo", @Num(vChoice))
                       
                 //This is were my MergeFilePrint code will go
                 writeln(TempTransType)
                 writeln(vbilledAmount)
                 writeln(vtransactionId)

}
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Read only table view subform
Reply #7 - Jul 3rd, 2007 at 2:46am
Print Post Print Post  
One thing that jumps out (though, not the answer to your question) is that if there are more than 9 transactions, you will not have them in numerical order. This can be fixed by adding a forward slash to the list of choices for @PopupMenu, like this: @PopupMenu(vEdits + "/;"  ,"choose to print")

The slash stops @PopupMenu from sorting the list. The side effect is that you will have a small arrow after the last choice on the list. You'll need to decide which is the lesser of two evils: numbers out of order, or a small, barely noticable arrow.

You may notice that I also removed the two double-quotes before vEdits. They weren't doing anything because you didn't have anything between them (not even a space).


Now, to answer you question. I have highlighted the parts that I added. This should strip out any of the transaction types that don't contain the word "Charge". I believe this is what you were asking for, yes?

var n as Int
var vCount as Int
var vEdits as String
var vChoice as String

var vbilledAmount as String
var vtransactionId as String
var vChargememo as String

If @Mode() < 2
{
     vCount = @FormResultSetTotal("Payments")
     
     If vCount = 1 Then
           If @FormFieldValue("Payments", "TransactionType", 1) = "" Then
                 vCount = 0
     
     For n = 1 to vCount
     
           If @Instr( @FormFieldValue("Transactions", "TransactionType", n), "Charge" ) > 0
                 vEdits = @AppendStringArray(vEdits, "Print Reminder for Transaction# " + n)
           //writeln(vedits)
     Next
     
     PopupSelectPosition(4, @XPos(ThisElement), @YPos(ThisElement))
     vChoice = @PopupMenu(vEdits + "/;"  ,"choose to print")
     
     TempTransType = @FormFieldVAlue("payments", "TransactionType", @Num(vChoice))
     vbilledAmount = @FormFieldVAlue("payments", "Billed Amount", @Num(vChoice))
     vtransactionId = @FormFieldVAlue("payments", "TransactionId", @Num(vChoice))
     //vChargememo = @FormFieldVAlue("payments", "ChargeMemo", @Num(vChoice))
     
     //This is were my MergeFilePrint code will go
     writeln(TempTransType)
     writeln(vbilledAmount)
     writeln(vtransactionId)
}
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Read only table view subform
Reply #8 - Jul 3rd, 2007 at 6:04am
Print Post Print Post  
Carl,

Thank You, Thank You, Thank you, Thank you.

Your code was great, I just had to understand @Instr() and modify it to my subform name. after that it was perfect!

         If @Instr( @FormFieldValue("payments", "TransactionType", n), "Charge" ) > 0
                vEdits = @AppendStringArray(vEdits, "Print Reminder for Transaction# " + n)

Thanks again, I will surely utilize what I learned from you, over and over again.
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Read only table view subform
Reply #9 - Jul 3rd, 2007 at 1:49pm
Print Post Print Post  
BOBSCOTT wrote on Jul 3rd, 2007 at 6:04am:
Carl,

Thank You, Thank You, Thank you, Thank you.

You're welcome.

Quote:
Your code was great, I just had to understand @Instr() and modify it to my subform name. after that it was perfect!

Ooops! Sorry about that. I had changed the subform name so that I could test it in one of my applications to verify that it would work as expected, and obviously forgot to change it back.
  


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