Hi Foxpro558
Below the code for a fully working demo for what your trying to do. Just copy it into a PRG file and run it.
Please have a look at the AfterRowColChange() method and the different Click() methods. I think they might lead you into the right direction.
Enjoy
MarK
***code starts here***********************************************
PUBLIC oForm
oForm = NEWOBJECT("form1")
ADDPROPERTY(oForm, "la_Sales[1]")
oForm.Show
Read Events
Close all
Clear All
RETURN
**************************************************
DEFINE CLASS chkBox1 AS CheckBox
Visible = .T.
Caption = " "
PROCEDURE Click()
LOCAL lc_Alias, li_RecNo
lc_Alias = ALIAS()
li_RecNo = RECNO(lc_Alias)
GOTO li_RecNo IN (lc_Alias)
Select SUM(N_Price) FROM curSalesSelection ;
WHERE curSalesSelection.L_Paid = .T. ;
INTO ARRAY Thisform.la_Sales
ThisForm.txtTotalSales.Value = ThisForm.la_Sales[1]
IF VARTYPE(ThisForm.la_Sales[1]) != "N"
ThisForm.txtTotalSales.Value = 0
Endif
ThisForm.Refresh()
ENDPROC
ENDDEFINE
DEFINE CLASS form1 AS Form
AutoCenter = .T.
Caption = "Sales"
Height = 480
Width = 660
MinHeight = This.Height
MinWidth = This.Width
ADD OBJECT lblLastName AS Label WITH ;
Caption = "Customer Lastname", ;
Left = 12, ;
Top = 6, ;
Anchor = 3
ADD OBJECT lblCustomers AS Label WITH ;
Caption = "Customer Names", ;
Left = 10, ;
Top = 30, ;
Anchor = 3
ADD OBJECT lblSelection AS Label WITH ;
Caption = "Sales", ;
Left = 300, ;
Top = 30, ;
Anchor = 1 + 2
ADD OBJECT grdCustomer AS Grid WITH ;
Left = 10, ;
Top = 48, ;
Width = 270, ;
Height = 408, ;
Anchor = 1 + 2 + 4, ;
Visible = .F.
PROCEDURE grdCustomer.AfterRowColChange()
LPARAMETERS nColIndex
SELECT * FROM curSales ;
WHERE curSelection.C_CID = curSales.C_CID ;
INTO CURSOR curSalesSelection READWRITE
IF _Tally > 0
WITH Thisform.grdSales
.Visible = .T.
.ColumnCount = -1
.RecordSource = "curSalesSelection"
.Column1.ReadOnly = .T.
.Column2.ReadOnly = .T.
.Column3.ReadOnly = .T.
.Column3.Sparse = .F.
.Column3.Text1.InputMask = "9999.99"
.Column4.Sparse = .F.
.Column4.AddObject("chkBoxSelection", "chkBox1")
.Column4.RemoveObject("Text1")
.Column4.CurrentControl = "chkBoxSelection"
ENDWITH
WITH Thisform
.cmdSave.Visible = .T.
.txtTotalSales.Visible = .T.
.txtTotalSales.Value = 0
ENDWITH
ELSE
WITH Thisform
.grdSales.Visible =.F.
.cmdSave.Visible = .F.
.txtTotalSales.Visible = .F.
ENDWITH
ENDIF
ThisForm.Refresh()
ENDPROC
ADD OBJECT grdSales AS Grid WITH ;
Left = 300, ;
Top = 48, ;
Width = 330, ;
Height = 342, ;
Anchor = 1 + 2 + 4 + 8, ;
Visible = .F.
ADD OBJECT txtTotalSales AS Textbox WITH ;
Left = 366, Top = 396, Height = 42, Width = 264, Value = 0, InputMask = "99999.99", Anchor = 2 + 4 + 8, Visible = .F. , ;
FontBold = .T., FontSize = 24
ADD OBJECT cmdSave AS CommandButton WITH ;
Left = 300, Top = 396, Height = 42, Width = 60, Caption = "Save", Anchor = 2 + 4, Visible = .F.
PROCEDURE cmdSave.Click()
= MESSAGEBOX("You saved your change", 0, "Sales out")
ENDPROC
ADD OBJECT txtCustomer AS Textbox WITH ;
Left = 120, Top = 6, Height = 21, Width = 120, Format = "!"
ADD OBJECT cmdSearch AS CommandButton WITH ;
Left = 252, Top = 6, Height = 21, Width = 90, Caption = "Search"
PROCEDURE cmdSearch.Click()
SELECT * FROM curCustomer ;
WHERE UPPER(curCustomer.C_LName) = ALLTRIM(UPPER(Thisform.txtCustomer.Value)) ;
INTO CURSOR curSelection
WITH Thisform.grdCustomer
.Visible = .T.
.ColumnCount = -1
.RecordSource = "curSelection"
ENDWITH
WITH ThisForm
.grdSales.Visible = .F.
.txtTotalSales.Visible =.F.
.cmdSave.Visible = .F.
.Refresh()
ENDWITH
ENDPROC
PROCEDURE Destroy
CLOSE ALL
Clear Events
ENDPROC
PROCEDURE Load
CREATE CURSOR curCustomer (C_CID C(3), C_LName C(20))
INSERT INTO curCustomer (C_CID, C_LName) VALUES ("CI1", "Smith Frank")
INSERT INTO curCustomer (C_CID, C_LName) VALUES ("CI2", "Smith Joe")
INSERT INTO curCustomer (C_CID, C_LName) VALUES ("CI3", "Klein Frank")
INSERT INTO curCustomer (C_CID, C_LName) VALUES ("CI4", "Klein Suzy")
INSERT INTO curCustomer (C_CID, C_LName) VALUES ("CI5", "Bogart Humphrey")
INSERT INTO curCustomer (C_CID, C_LName) VALUES ("CI6", "Peter Dummy")
LOCATE
CREATE CURSOR curSales (C_CID C(3), C_Descri C(20), N_Price N(4,2), L_Paid L)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI1", "Description", 4.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI1", "Description", 14.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI1", "Description", 24.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI1", "Description", 34.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI2", "Description", 54.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI2", "Description", 64.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI2", "Description", 47.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI2", "Description", 48.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI3", "Description", 44.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI3", "Description", 42.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI3", "Description", 64.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI4", "Description", 94.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI4", "Description", 84.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI4", "Description", 74.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI5", "Description", 64.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI5", "Description", 104.25, .F.)
ENDPROC
ENDDEFINE
***code ends here*********************************************