Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grid text1 losing it's click event 2

Status
Not open for further replies.

CMcC

Programmer
Feb 5, 2002
196
US
Hi all -
Having trouble figuring out why my grid1.column3.text1.click() doesnt work a second time.
It seems to work the first time it is clicked, but then after the first time - it doesnt.
here is what I have in the click event of the text1 in the grid on a form called frmchecks:
Code:
If Empty(This.Value)
	If Messagebox("Enter Check Information Now?",4+32+256,"Please Confirm") == 6
		Do Form frmexistcheck With Thisform.custnum,chktemp.chg_bk_dte
	Endif
Else
	Do Form frmshowcheck With Thisform.custnum,chktemp.chg_bk_dte
ENDIF
Thisform.Release()

To get to the form containing the grid in question, the user presses a button on a calling form, and that code is as follows:
Code:
DO FORM frmchecks WITH thisform.custnum
When this form (frmchecks) is released, it sets the focus back to the previous calling form and the user can click the button again to call the above code again.
After I come back to this form(frmchecks) a second time, the click event no longer fires.
Any suggestions?
Thanks
CMcc
 
Why do you have "Thisform.Release()" in your form if you're trying to return to it?

It would appear to me that the Thisform.Release() code is firing, but since you've instantiated a child form, "Thisform" can't be released until the child form is released, so it just sits there dead in the water.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
HI Dave - I've tried many things. I've taken out the release() and have a form method called thisform.refill() where I call a select statement and fill in my grid again (once the child form is released and the focus gets back to FRMCHECKS), however, it doesnt fill it in correctly.
I have 10 columns in the grid, but when I edit something and call the method REFILL - it doesnt fill correctly. It completely loses the third column (which the I have the text1.click() event in. ( the third column is there but it is not the Check # field which it supposed to be - and the click event still doesnt work for that column)


Here is what I call in the init and also in a form method called REFILL() on the form FRMCHECKS-
Code:
SELECT checks
SELECT * FROM checks WHERE STR(cust_num,6) = STR(customer,6) INTO CURSOR chktemp
thisform.fillgrid()

Here is thisform.fillgrid()
Code:
thisform.grid1.RecordSource = ''


With Thisform.grid1
	Select chktemp
	.RecordSource = "chktemp"
	.ColumnCount = 10
	.column1.ReadOnly = .T.
	.column1.ControlSource = "chktemp.trans_nr"
	.column1.header1.Caption = "Trans #1"
	.column1.Width = 80

	.column2.ReadOnly = .T.
	.column2.ControlSource = "chktemp.trans2_nr"
	.column2.header1.Caption = "Trans #2"
	.column2.Width = 80

	.column3.ReadOnly = .T.
	.column3.ControlSource = "chktemp.chk_num"
	.column3.header1.Caption = "Check #"
	.column3.Width = 60

	.column4.ReadOnly = .T.
	.column4.ControlSource = "chktemp.chg_bk_dte"
	.column4.header1.Caption = "Charged Back"
	.column4.Width =82

	.column5.ControlSource = "chktemp.chk_amt"
	.column5.header1.Caption = "Amount"
	.column5.Format = "$"
	.column5.ReadOnly = .T.
	.column5.Width = 70

	.column6.ControlSource = "chktemp.penalty"
	.column6.header1.Caption = "Penalty"
	.column6.Format = "$"
	.column6.ReadOnly = .T.
	.column6.Width = 70

	If chktemp.lett_date3 >= chktemp.lett_date2 .And. chktemp.lett_date3 >= chktemp.lett_date1
		.column7.ControlSource = "chktemp.letter3"
	Else
		If chktemp.lett_date2 >= chktemp.lett_date3 .And. chktemp.lett_date2 >= chktemp.lett_date1
			.column7.ControlSource = "chktemp.letter2"
		Else
			If chktemp.lett_date1 >= chktemp.lett_date2 .And. chktemp.lett_date1 >= chktemp.lett_date3
				.column7.ControlSource = "chktemp.letter1"
			Endif
		Endif
	Endif
	.column7.header1.Caption = "Letter"
	.column7.ReadOnly = .T.
	.column7.Width = 70

	.column8.ControlSource = "chktemp.Inits"  && want an iif statement here
	.column8.header1.Caption = "Inits"
	.column8.ReadOnly = .T.
	.column8.Width = 80

	.column9.ControlSource = "gt_agname(chktemp.agency)"  && want an iif statement here
	.column9.header1.Caption = "Agency"
	.column9.ReadOnly = .T.
	.column9.Width = 100
	.column9.Sparse = .T.

	.column10.ControlSource = "iif(chktemp.paid,'Y','N')"  && want an iif statement here
	.column10.header1.Caption = "Paid"
	.column10.ReadOnly = .T.
	.column10.Width = 70
	.column10.Sparse = .T.

	Select chktemp
	Go Top
	.SetAll([DynamicBackColor],"IIF (chktemp.paid = .t., RGB(0,128,0),RGB(0,0,0))",[Column])
	.Refresh()
	Thisform.Refresh()
Endwith

I have changed the click event (in column3.text1 of the grid) -
Code:
If Empty(This.Value)
	If Messagebox("Enter Check Information Now?",4+32+256,"Please Confirm") == 6
		Do Form frmexistcheck With Thisform.custnum,chktemp.chg_bk_dte
	Endif
Else
	Do Form frmshowcheck With Thisform.custnum,chktemp.chg_bk_dte
ENDIF

thisform.refill()

I was releasing the form to clear everything and open it again - but seems the grid doesnt work because of what you said....now having the problem of the grid not filling correctly.

It actually adds a field that is the CHECKS table called 'escrow' as the 10th column header and field data, (and I made sure it is not taking the first 10 fields of the table CHECKS) - although 'escrow' is the 10th field of the table CHECKS. (interesting) -

It still has all my headers that I name in fillgrid(), except CHECK # is gone and 'escrow' is placed at the 10th column header. No where in my code do I set a header to = "Escrow"....
Any other suggestions?
Thanks for your time
Cmcc
 
Found out something else - if in my form method REFILL I change the code to:
Code:
SELECT checks
SELECT * FROM checks WHERE STR(cust_num,6) = STR(thisform.custnum,6) INTO CURSOR [red]newtemp[/red]
[red]thisform.fillgridagain()[/red]
then have a new method called thisform.fillgridagain()
Code:
thisform.grid1.RecordSource = ''

With Thisform.grid1
	Select newtemp
	.RecordSource = "newtemp"
	.ColumnCount = 10
	.column1.ReadOnly = .T.
	.column1.ControlSource = "newtemp.trans_nr"
	.column1.header1.Caption = "Trans #1"
	.column1.Width = 80

	.column2.ReadOnly = .T.
	.column2.ControlSource = "newtemp.trans2_nr"
	.column2.header1.Caption = "Trans #2"
	.column2.Width = 80

	.column3.ReadOnly = .T.
	.column3.ControlSource = "newtemp.chk_num"
	.column3.header1.Caption = "Check #"
	.column3.Width = 60

	.column4.ReadOnly = .T.
	.column4.ControlSource = "newtemp.chg_bk_dte"
	.column4.header1.Caption = "Charged Back"
	.column4.Width =82

	.column5.ControlSource = "newtemp.chk_amt"
	.column5.header1.Caption = "Amount"
	.column5.Format = "$"
	.column5.ReadOnly = .T.
	.column5.Width = 70

	.column6.ControlSource = "newtemp.penalty"
	.column6.header1.Caption = "Penalty"
	.column6.Format = "$"
	.column6.ReadOnly = .T.
	.column6.Width = 70

	If newtemp.lett_date3 >= newtemp.lett_date2 .And. newtemp.lett_date3 >= newtemp.lett_date1
		.column7.ControlSource = "newtemp.letter3"
	Else
		If newtemp.lett_date2 >= newtemp.lett_date3 .And. newtemp.lett_date2 >= newtemp.lett_date1
			.column7.ControlSource = "newtemp.letter2"
		Else
			If newtemp.lett_date1 >= newtemp.lett_date2 .And. newtemp.lett_date1 >= newtemp.lett_date3
				.column7.ControlSource = "newtemp.letter1"
			Endif
		Endif
	Endif
	.column7.header1.Caption = "Letter"
	.column7.ReadOnly = .T.
	.column7.Width = 70

	.column8.ControlSource = "newtemp.Inits"  && want an iif statement here
	.column8.header1.Caption = "Inits"
	.column8.ReadOnly = .T.
	.column8.Width = 80

	.column9.ControlSource = "gt_agname(newtemp.agency)"  && want an iif statement here
	.column9.header1.Caption = "Agency"
	.column9.ReadOnly = .T.
	.column9.Width = 100
	.column9.Sparse = .T.

	.column10.ControlSource = "iif(newtemp.paid,'Y','N')"  && want an iif statement here
	.column10.header1.Caption = "Paid"
	.column10.ReadOnly = .T.
	.column10.Width = 70
	.column10.Sparse = .T.

	Select newtemp
	Go Top
	.SetAll([DynamicBackColor],"IIF (newtemp.paid = .t., RGB(0,128,0),RGB(0,0,0))",[Column])
	.Refresh()
	Thisform.Refresh()
Endwith
I can see the check # field and the click event works ...but for only one more time....I cannot keep changing the name of the cursor justto keep the grid looking properly. Any help????? please!
Thanks...cmcc
 
If you change the recordsource of a grid rather than remove and reset it, the grid pretty much goes back to its default state prior to you changing anything.

Try it this way:

In the REFILL method:
Code:
thisform.grid1.RecordSource = ''   &&... here
SELECT * FROM checks ;
   WHERE STR(cust_num,6) = STR(thisform.custnum,6) ;
   INTO CURSOR newtemp
thisform.fillgridagain()
Then in thisform.fillgrid() or thisform.fillgridagain()
Code:
*... thisform.grid1.RecordSource = ''  &&... not here

With Thisform.grid1
    Select newtemp
    .RecordSource = "newtemp"
    .ColumnCount = 10

.
.
.
and so on


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Cmcc,

I'm not sure I've followed this completely, but I do agree with Dave's last point. When you run the SELECT, you will destroy the cursor that populates the grid. When you do that, the grid temporarily loses all its columns and all its controls, including all the code in the controls's methods.

That would explain why the Click event no longer fires. The code isn't there any more.

For a possible solution, see
Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Thank you Dave and Mike! That was it. I was setting the recordsource = '' in ithe wrong place. Kudos! and Happy New Year!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top