Solved

VFP 9 hiding value in a grid row/column based on a date in the record

Posted on 2010-09-04
5
1,506 Views
Last Modified: 2012-05-10
I have a grid in a form that contains a Loan Amount field. Above the grid is a year (2010,2009, etc.) in a combobox. If a year for a date field in the same grid that contains the Loan Amount field is the same as the selected year in the combobox the Loan Amount should show otherwise it shouldn't. I have made this work properly but when I try to edit the value in the Loan Amount field, in the status bar of the application it says that this is read-only. Here is the code that I have put into the INIT of the grid to make the hide/show functionality work properly:

this.column6.ControlSource = + ;
 "IIF(ALLTRIM(STR(YEAR(loan.date_req))) == thisform.pageframe1.page12.txtPlanYear.value, + ;
 loan.loan_amt,'')"

Any ideas would be greatly appreciated!
0
Comment
Question by:Thomas Swaney
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 33605831
Yes, as you have an expression as the controlsource, the controlsource get's readonly automatic. It's not like you perhpas think, that some of the textboxes of the column have a controlsource of '' and others have a controlsourece of loan.loan_amt. Ther is only one textbox in the column, it's only drawn for each record, but there is only the one control in the active record, and this has the expression as it's controlsource and therefore is not bound to a field it could write to or update, that's making it readonly.

You should rather add an unbound textbox or perhpas even a control without a value property, like a container object to the grid column (eg column.addobject("container1","container")  and use the Dynamiccurrentcontrol of the column via

this.column6.dynamiccurrentcontrol = "IIF(ALLTRIM(STR(YEAR(loan.date_req))) == thisform.pageframe1.page12.txtPlanYear.value, + ;
"text1","container1")"

And use the controlsource of the column rather than the control within the column.

Bye, Olaf.
0
 
LVL 2

Author Comment

by:Thomas Swaney
ID: 33607172
Thanks Olaf.

I have tried this adding two textbox controls to the grid column and adding the code that you suggested to the Init of the grid.

Unless I add the controlsource of loan.loan_amt for the grid column it shows the first column from the loan table as the value in the grid column.

Text1 has a controlsource of loan.loan_amt
Text2 has a empty controlsource.

So in other words it is still not working properly. I could maybe try another control but I would think that I would get the same results.

Have you got a application that this is working in currently or have you tested it?

Thanks,
Thomas
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 33607275
The controlsource of controls in a grid column rather "inherits" the controlsource of the colun, true. It's mainly the grid that binds to the table, not the inner controls. So what's wrong about setting the column controlsource to  loan.loan_amt?

Set column.sparse=.f. perhaps.

I don't see why this would not work, I'll create such a grid now and test.

Bye, Olaf.

0
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 33607384
Yes, Sparse=.F. solves it. Before that the loan also shows in the rows not meeting the iif condition.

And yes, the column.controlsource is set to "loan.loan_amt", not the text1.controlsource and of course not the container1, which has no controlsource and value property.

You may also set container1.backstyle=0 and container1.borderwidth=0 to make the grid cell look normal and empty.

Bye, Olaf.
0
 
LVL 2

Author Closing Comment

by:Thomas Swaney
ID: 33613157
Thank you. Works great!!
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question