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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'Field' phrase not found 4

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
578
0
16
PH
Hi everyone.. please help me what im i missing, it keeps on saying field phrase not found... thanks....

ADD OBJECT combo1 AS COMBOBOX WITH ; && Name
RowSourceType = 6, RowSource = "MyDataB",;
Height = 23, ;
Left = 305, ;
Top = 5, ;
Width = 210

PROCEDURE Load

SELECT tsulat.sname,fname,idnum FROM sms ORDER BY tsulat.sname,fname INTO CURSOR MyDataB
SELECT pay.P1, P2, P3, P4, P5, P6, P7, P8, P9, P10 FROM PAYOLA ORDER BY P1 INTO CURSOR MyPayTui
SELECT pay.BACK1, BACK2, BACK3, BACK4, BACK5 FROM PAYOLA ORDER BY BACK1 INTO CURSOR MyPayBack
SELECT pay.BOOK1, BOOK2, BOOK3, BOOK4, BOOK5 FROM PAYOLA ORDER BY BOOK1 INTO CURSOR MyPayBooks
SELECT pay.UNI1, UNI2, UNI3, UNI4, UNI5 FROM PAYOLA ORDER BY UNI1 INTO CURSOR MyPayUNi

ENDPROC

PROCEDURE Init

SET TALK OFF
SET BELL OFF
SET CENTURY ON
SET CONFIRM OFF
SET SAFETY OFF
SET ECHO OFF
SET ESCAPE OFF
SET AUTOSAVE ON

SELECT 2
USE payola EXCLUSIVE ALIAS pay
INDEX ON IDNUM TO IDNUMX

SELECT 1
USE SMS exclusive ALIAS TSULAT
INDEX ON IDNUM TO IDNUMX2

SET RELATION TO IDNUM INTO pay

this.oGrid1.width = 400
this.oGrid1.Column1.Width = 100

this.oGrid1.Column1.Header1.caption = "Name of Student"
this.oGrid1.Column1.Header1.fontname = "Bernard MT Condensed"
*this.oGrid1.Column2.Header1.FontSize = 11
this.oGrid1.Column1.Width = 120

this.oGrid1.Column2.Header1.caption = "ID Number"
this.oGrid1.Column2.Header1.fontname = "Bernard MT Condensed"
*this.oGrid1.Column2.Header1.FontSize = 11
this.oGrid1.Column2.Width = 150

PROCEDURE combo1.click()

SELECT 1

SEEK ALLTRIM(MyDataB.idnum)

IF FOUND()

SELECT 2

this.oGrid2.RecordSource = SPACE(0)

SELECT P1,P2,P3,P4,P5,P6,P7,P8,P9,P10 FROM PAYMENTS WHERE idnum = ALLTRIM(MyDataB.idnum) INTO CURSOR MyPayTui
this.oGrid2.RecordSource = "MyPayTui"

this.oGrid3.RecordSource = SPACE(0)

SELECT BACK1,BACK2,BACK3,BACK4,BACK5 FROM PAYMENTS WHERE idnum = ALLTRIM(MyDataB.idnum) INTO CURSOR MyPayBack
this.oGrid3.RecordSource = "MyPayBack"

this.oGrid4.RecordSource = SPACE(0)

SELECT BOOK1,BOOK2,BOOK3,BOOK4,BOOK5 FROM PAYMENTS WHERE idnum = ALLTRIM(MyDataB.idnum) INTO CURSOR MyPayBooks
this.oGrid4.RecordSource = "MyPayBooks"

this.oGrid5.RecordSource = SPACE(0)

SELECT UNI1,UNI2,UNI3,UNI4,UNI5 FROM PAYMENTS WHERE idnum = ALLTRIM(MyDataB.idnum) INTO CURSOR MyPayUni
this.oGrid5.RecordSource = "MyPayUni"

ENDIF
 
Hello everyone.. for almost 4 days i am still trying to figure out what caused the field phrase not found... i have done what mike said to create new form and gradually add other things... but when i add combobox, field phrase persistently appear... may i ask help from anyone... here are the codes... i have removed most of he objects and other things.. thanks in advance...

DEFINE CLASS mypage5 as Page

FontBold = .T.
Caption = "Students Record"
Forecolor = rgb(128,0,0)

ADD OBJECT oGrid1 AS Grid WITH ;
RecordSource="MyDataB", ;
ColumnCount=2, ;
Width = 200, ;
Top = 50, ;
Height = 100, ;
FontSize = 10, ;
left = 300,;
Wordwrap = .t.

ADD OBJECT text90 AS COMBOBOX WITH ; && Name
RowSourceType = 7, RowSource = "MyDataB",;
columncount = 2,;
Height = 23, ;
Left = 305, ;
Top = 5, ;
Width = 210

ADD OBJECT Text1 AS combobox WITH ; &&
Height = 32, ;
Left = 400, ;
Top = 337, ;
Width = 150,;
RowSourceType = 1, RowSource = "\<School Fees,\<Back,\<Books,\<Uniform,",;
decimals = 2,;
fontsize = 11

ADD OBJECT oButton2 AS CommandButton WITH ;
TOP = 380,;
Left = 600, ;
Height = 35, ;
Width = 100, ;
fontname = "BRITANNIC BOLD",;
FontSize = 14, ;
ForeColor = RGB(0,128,128),;
Caption = "OK"

PROCEDURE load()

SELECT ALLTRIM(sname) + ", " + ALLTRIM(fname), idnum FROM SMS ORDER BY sname, fname INTO CURSOR MyDataB

ENDPROC


PROCEDURE oGrid1.Init()

this.parent.oGrid1.width = 400
this.parent.oGrid1.Column1.Width = 100

this.parent.oGrid1.Column1.Header1.caption = "Name of Student"
this.parent.oGrid1.Column1.Header1.fontname = "Bernard MT Condensed"
this.parent.oGrid1.Column1.Width = 120

this.parent.oGrid1.Column2.Header1.caption = "ID Number"
this.parent.oGrid1.Column2.Header1.fontname = "Bernard MT Condensed"
this.parent.oGrid1.Column2.Width = 150

ENDPROC

PROCEDURE text1.click()

SELECT 1

SET relation TO idnum INTO pay

IDNAMBER = ALLTRIM(this.parent.text1.value)

this.parent.oGrid1.RecordSource = SPACE(0)

SELECT ALLTRIM(sname) + ", "+ ALLTRIM(fname), idnum FROM sms WHERE idnum = ALLTRIM(this.parent.text1.value) INTO CURSOR MyDataB

this.parent.oGrid2.RecordSource = SPACE(0)

ENDPROC

PROCEDURE oButton2.Click

SELECT 2

SEEK ALLTRIM(idnum)

for i=1 to 10

m.deyta = "P"+transform(m.i)

IF &deyta=0
replace &deyta with this.parent.text31.value
this.parent.oGrid2.refresh()
MESSAGEBOX("Recorded!",0+64,"Students' Record 2021")
EXIT
ENDIF

IF i = 10
MESSAGEBOX("No more!",0+64,"Students' Record 2021")
ENDIF
NEXT

this.parent.Refresh()

endproc


ENDDEFINE
 
Why not try adding the combobox, but not setting the properties below until the form has initiated?

RowSourceType = 7, RowSource = "MyDataB",;
columncount = 2,;

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Mandy, this is somewhat confusing.

In the first code that you posted, you had one combo, with a RowSourceType of 6. The error message specifically related to that situation, and is caused by an incorrect setting of the RowSource. I explained that at the outset.

I later suggested that you start a new form from scratch and gradually add controls until the problem re-appears, which you say you have done. But, in your latest code, you now have two combos. One has a RowSourceType of 1, with a RowSource consisting of a list of hard-coded value. Syntactically, that looks correct (except perhaps for the spurious comma after "Uniform", but let's not worry about that). The other combo has a RowSourceType of 7, with a RowsSource containing a single filename, which doesn't make any sense.

It's hard to for us to follow what is happening when you change the context in this way. Also, I asked you to post the minimum code that would enable us to reproduce the problem. What you now given us is a definition of a class, which is based on the Page class. As it stands, that is no help at all. We don't know how you are going to use that class definition, or how it will lead to the error arising. Without that context, we have no way of reproducing the problem. And you have also included a lot of code not related to the problem, which does nothing to help us understand what is going on.

If it is at all possible for you to create the minimum form that reproduces the problem, we will do our best to help.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks so much Mike... I will still try to solve the problem first to the best of my ability before i ask help from you all... i really want to learn...
 
Hi Mandy,

I rearranged your code and deleted some syntax quirks in order to make it more readable. I also annotated it in order to show where some of the hick-ups are.

p.s. Why the ComboBox "Text90" since you don't do anything with its results? Btw oButton2.Click() doesn't do anything either

Code:
DEFINE CLASS mypage5 as Page

	FontBold = .T.
	Caption = "Students Record"
	Forecolor = rgb(128,0,0)

	ADD OBJECT oGrid1 AS Grid WITH ;
		RecordSource = "MyDataB", ;
		ColumnCount = 2, ;
		Width = 200, ;
		Top = 50, ;
		Height = 100, ;
		FontSize = 10, ;
		left = 300, ;
		Wordwrap = .t.
		
		PROCEDURE oGrid1.Init()

			WITH This
[highlight #FCE94F]				.width = 400 && why define twice see above
[/highlight]
				.Column1.Header1.caption = "Name of Student"
				.Column1.Header1.fontname = "Bernard MT Condensed"
				.Column1.Width = 120

				.Column2.Header1.caption = "ID Number"
				.Column2.Header1.fontname = "Bernard MT Condensed"
				.Column2.Width = 150
			ENDWITH 
		ENDPROC

	ADD OBJECT text90 AS COMBOBOX WITH ; 
[highlight #FCE94F]		RowSourceType = 7, ; && does not make sense in this case - please choose appropriate type number
		RowSource = "MyDataB", ; && you have to specify the fields[/highlight]
		columncount = 2, ;
		Height = 23, ;
		Left = 305, ;
		Top = 5, ;
		Width = 210

	ADD OBJECT Text1 AS combobox WITH ; && 
		Height = 32, ;
		Left = 400, ;
		Top = 337, ;
		Width = 150, ;
		RowSourceType = 1, ;
		RowSource = "\<School Fees,\<Back,\<Books,\<Uniform", ;
		decimals = 2, ;
		fontsize = 11
		
		PROCEDURE text1.click()

[highlight #FCE94F]			SELECT 1 && please select Alias()
[/highlight]
			SET relation TO idnum INTO pay

			IDNAMBER = ALLTRIM(this.value)

	[highlight #FCE94F]		this.parent.oGrid1.RecordSource = SPACE(0) && does not make sense
[/highlight]
			SELECT ALLTRIM(sname) + ", "+ ALLTRIM(fname), idnum FROM sms WHERE idnum = ALLTRIM(this.value) INTO CURSOR MyDataB

[highlight #FCE94F]			this.parent.oGrid2.RecordSource = SPACE(0) && hence your grid does NOT show any data
[/highlight]
		ENDPROC
		
	ADD OBJECT oButton2 AS CommandButton WITH ;
		TOP = 380, ;
		Left = 600, ;
		Height = 35, ;
		Width = 100, ;
		fontname = "BRITANNIC BOLD", ;
		FontSize = 14, ;
		ForeColor = RGB(0,128,128), ;
		Caption = "OK"


		PROCEDURE oButton2.Click

	[highlight #FCE94F]		SELECT 2
[/highlight]
[highlight #FCE94F]			SEEK ALLTRIM(idnum) && is the cursor indexed?
[/highlight]
			for i=1 to 10

			m.deyta = "P"+transform(m.i)

                                IF &deyta = 0
                                        replace &deyta with this.parent.text31.value
					this.parent.oGrid2.refresh()
					MESSAGEBOX("Recorded!",0+64,"Students' Record 2021")
					EXIT
				ENDIF

				IF i = 10
					MESSAGEBOX("No more!",0+64,"Students' Record 2021")
				ENDIF
			NEXT

			this.parent.Refresh()

		ENDPROC 

[highlight #FCE94F]*!*			PROCEDURE load() && a page does not have a load method/event

*!*				SELECT ALLTRIM(sname) + ", " + ALLTRIM(fname), idnum FROM SMS ORDER BY sname, fname INTO CURSOR MyDataB

*!*			ENDPROC[/highlight]

ENDDEFINE

hth

MarK
 
I will still try to solve the problem first to the best of my ability before i ask help from you all.

Mandy, I am definitely not saying that you should not ask for help. Rather, that we need a clear and concise explanation of the problem in order to solve it - and ideally in a way that lets us reproduce the problem. The last thing I want to do is to discourage you from asking questions.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
hi Mike... i am really really sorry from the bottom of my heart, you might have interpreted what i meant... i am just so ashamed that i always ask for solutions from you all.... im really really sorry.. hope you would still help me.... thanks so much Mike... God Bless
 
Thank you so much mjcmkrsr... very comprehensive... so helpful, hence i will know where to start checking.... God bless you...
 
Hi mjcmkrsr... i was able to get rid of the field phrase problem... after i have followed all your suggestions... The page is now showing the data, however in my combobox, it does show the data in the cursor even though i have changed the RowSourceType = 6, ;RowSource = "MyDataB", ; but in the combobox it is showing another table not the Cursor (MyDataB). is there something i am missing? thanks in advanced mjcmkrsr and everyone.... God Bless.....
 
Hi Mandy,

Do you mean

Code:
ADD OBJECT text90 AS COMBOBOX WITH ; 
		RowSourceType = 7, ; && does not make sense in this case - please choose appropriate type number
		RowSource = "MyDataB", ; && you have to specify the fields
		columncount = 2, ;
		Height = 23, ;
		Left = 305, ;
		Top = 5, ;
		Width = 210

If yes - you just may delete that snippet since it doesn't do anything. NO PROCEDURE text90.... statement is following

If no - please show the code

hth

MarK
 
Hi Mandy,

Please find below a demo integrating YOUR (adapted) code. It is just a sketch of how you COULD achieve your goals - I made three assumptions - that you have one table for the students, one for the books and one for the fees. However I did nor relate them (parent-children relation) - but that could easily be done (cCode could be the link field).

Playground: You choose a name on the grid, choose an item from the combobox and you go. Enjoy

Code:
PUBLIC go_Form

go_Form = CREATEOBJECT("frmForm")
go_Form.Visible = .T.
go_Form.Show

READ Events

CLOSE ALL 
CLEAR ALL
RETURN 

*********

DEFINE CLASS frmForm As Form
	Width = 480
	MinWidth = 480
	MaxWidth = 480
	Height = 450
	MinHeight = 450
	AutoCenter = .T.
	Caption = "Grids - Editbox versus MemoField"
	ShowTips = .T.
	Themes = .F.
	
	
	ADD OBJECT pgfNames as Pageframe WITH ;
		Top = 12, ;
		Left = 12, ;
		Height = 450 - 24 - 42 , ;
		Width = 480 - 24, ;
		Anchor = 15, ;
		PageCount = 2
		
		PROCEDURE pgfNames.Init()
			LOCAL loPage as Object
			
			FOR i = 1 TO This.PageCount
				loPage = This.Pages(i)
				loPage.AddObject("grdNames","grdBase")
				loPage.grdNames.RecordSource = ICASE(i = 1, "csrBooks", "csrFees")

				loPage.Caption = ICASE(i = 1, "Books", "Fees")

			ENDFOR 
[highlight #FCE94F]
			This.AddObject("pagPage3","claPage")
[/highlight]
		ENDPROC 
		
		PROCEDURE pgfNames.Page1.Click()
			This.grdNames.Visible = .T.
			This.Refresh()
		
		ENDPROC 

		PROCEDURE pgfNames.Page2.Click()
			This.grdNames.Visible = .T.
			This.Refresh()
		
		ENDPROC 
		
	ADD OBJECT cmdExit As CommandButton WITH ;
    	Width = 60, Height = 30, Left = 480 - 12 - 60, Top = 450 - 12 - 30, Caption = "Exit", Anchor = 12
    	
		PROCEDURE cmdExit.Click()
			ThisForm.Release
			CLEAR Events
		
		ENDPROC
		
	PROCEDURE Load()
	
		CREATE CURSOR csrdemo (cCode C(3), cName C(10), cGender C(1), tDTime T)
		
		INSERT INTO csrdemo VALUES ('001','Henry','M',DATETIME() - 6)
		INSERT INTO csrdemo VALUES ('011','Jenny','F',DATETIME() - 5)
		INSERT INTO csrdemo VALUES ('004','Eve','F',DATETIME() - 4)
		INSERT INTO csrdemo VALUES ('005','Lauren','F',DATETIME() - 3)
		INSERT INTO csrdemo VALUES ('009','Bob','M',DATETIME() - 2)
		INSERT INTO csrdemo VALUES ('006','Sharon','F',DATETIME() - 1)
		
		LOCATE 

		CREATE CURSOR csrBooks (cCode C(3), cName C(10), cTitle C(25), tDTime T)

		CREATE CURSOR csrFees (cCode C(3), cName C(10), iFees I, tDTime T)
		
	ENDPROC
			
	PROCEDURE Destroy()
		This.cmdExit.Click()
	
	ENDPROC 
ENDDEFINE 

*********
DEFINE CLASS grdBase as Grid 
	Visible = .F.
	Top = 12
	Left = 12
	Width = 480 - 24 - 24
	Height = 450 - 24 - 48 - 48
	BackColor = RGB(0, 246, 246)
	RowHeight = 21
	AllowRowSizing = .F.
	HeaderHeight = 21
	AllowHeaderSizing = .F.
	Anchor = 15
	ReadOnly = .T.
	DeleteMark = .F.
	ColumnCount = -1

	PROCEDURE Init()
		WITH This
			.Column1.Header1.Caption = "ID"
			.Column2.Header1.Caption = "Name"
			.Column3.Header1.Caption = "Title"
			.Column4.Header1.Caption = "DateTime"
		ENDWITH 
	ENDPROC 
ENDDEFINE 

*********

[highlight #FCE94F]DEFINE CLASS claPage as Page

	FontBold = .T.
	Caption = "Students Record"
	Forecolor = rgb(128,0,0)

	ADD OBJECT oGrid1 AS Grid WITH ;
		RecordSource = "csrDemo", ;
		ColumnCount = 2, ;
		Width = 480 - 48, ;
		Top = 54, ;
		Height = 450 - 24 - 42 - 24 - 24 - 54, ;
		FontSize = 10, ;
		left = 12,;
		Wordwrap = .t.

		PROCEDURE oGrid1.Init()

			this.Column1.Header1.caption = "Name of Student"
			this.Column1.Header1.fontname = "Bernard MT Condensed"
			this.Column1.Width = 120

			this.Column2.Header1.caption = "ID Number"
			this.Column2.Header1.fontname = "Bernard MT Condensed"
			this.Column2.Width = 150

		ENDPROC

	ADD OBJECT cboSFBBU AS combobox WITH ; && 
		Height = 24, ;
		Left = 12, ;
		Top = 12, ;
		Width = 150, ;
		RowSourceType = 1, ;
		RowSource = "\<School Fees,\<Back,\<Books,\<Uniform", ;
		fontsize = 10
		
		PROCEDURE cboSFBBU.click()
*!*			your code goes here an delete the code below
		
			WAIT WINDOW + "You selected student " + ALLTRIM(csrDemo.cName) + " and the table "+ This.Value NOWAIT 
			
		ENDPROC
		
	ADD OBJECT cmdButton AS CommandButton WITH ;
		TOP = 12, ;
		Left = 174, ;
		Height = 24, ;
		Width = 48, ;
		fontname = "BRITANNIC BOLD", ;
		FontSize = 14, ;
		ForeColor = RGB(0,128,128), ;
		Caption = "OK"

		PROCEDURE cmdButton.Click()
*!*				your code goes here and delete the code below
			
			DO CASE 
				CASE This.Parent.cboSFBBU.List(This.Parent.cboSFBBU.ListIndex,1) = "School Fees"
					
					INSERT INTO csrFees VALUES (csrDemo.cCode, csrDemo.cName, 250, DATETIME())

					WAIT WINDOW + "Fees added for " + ALLTRIM(csrDemo.cName) +" in table " + This.Parent.cboSFBBU.Value TIMEOUT 3 

				CASE This.Parent.cboSFBBU.List(This.Parent.cboSFBBU.ListIndex,1) = "Back"
					
					WAIT WINDOW + "You may add data for " + ALLTRIM(csrDemo.cName) + " into table [Back]" TIMEOUT 2

				CASE This.Parent.cboSFBBU.List(This.Parent.cboSFBBU.ListIndex,1) = "Books"

					INSERT INTO csrBooks VALUES (csrDemo.cCode, csrDemo.cName, "Any Book", DATETIME())

					WAIT WINDOW + "Book added for " + ALLTRIM(csrDemo.cName) +" in table " + This.Parent.cboSFBBU.Value TIMEOUT 3 

				CASE This.Parent.cboSFBBU.List(This.Parent.cboSFBBU.ListIndex,1) = "Uniform"
					
					WAIT WINDOW + "You may add data for " + ALLTRIM(csrDemo.cName) + " into table [Uniforms]" TIMEOUT 2
					
				OTHERWISE 
					
					WAIT WINDOW + "No table select" TIMEOUT 5
				
			ENDCASE 
			

		
		ENDPROC 

ENDDEFINE
*********
[/highlight]

hth

MarK
 
Thank you Mark for this... I'll try to understand it well.... I'll keep you posted always Mark.... Thanks so much....
 
Hi Mandy

... and a more user friendly version. Enjoy.

Code:
PUBLIC go_Form

go_Form = NEWOBJECT("frmForm")
go_Form.Visible = .T.
go_Form.Show

READ Events

CLOSE ALL 
CLEAR ALL
RETURN 

*********

DEFINE CLASS frmForm As Form
	Width = 480
	MinWidth = 480
	MaxWidth = 510
	Height = 450
	MinHeight = 450
	AutoCenter = .T.
	Caption = "Students - Fees - Books"
	ShowTips = .T.
	Themes = .F.
	
	
	ADD OBJECT pgfNames as Pageframe WITH ;
		Top = 12, ;
		Left = 12, ;
		Height = 450 - 24 - 42 , ;
		Width = 480 - 24, ;
		Anchor = 15, ;
		PageCount = 0
		
		PROCEDURE pgfNames.Init()
			LOCAL loPage as Object
			
			WITH This
				.NewObject("Page1","pagBase")
				.NewObject("Page2","Page")
				.NewObject("Page3","Page")
				.NewObject("Page4","Page")
				.NewObject("Page5","Page")

			ENDWITH 

			FOR i = 2 TO 5
				loPage = This.Pages(i)
				WITH loPage
					.Caption = ICASE(i = 2, "Fees", i = 3, "Back", i = 4, "Books", "Uniform")
					.NewObject("grdNames","grdBase")
					.grdNames.Visible = .F.

				ENDWITH 
			ENDFOR 
		ENDPROC 
		
	ADD OBJECT cmdExit As CommandButton WITH ;
    	Width = 60, Height = 30, Left = 480 - 12 - 60, Top = 450 - 12 - 30, Caption = "Exit", Anchor = 12
    	
		PROCEDURE cmdExit.Click()
			ThisForm.Release
			CLEAR Events
		
		ENDPROC
		
	PROCEDURE Load()
	
		CREATE CURSOR csrdemo (cCode C(3), cName C(10), cGender C(1), tDTime T)
		
		INSERT INTO csrdemo VALUES ('001','Henry','M',DATETIME() - 6)
		INSERT INTO csrdemo VALUES ('011','Jenny','F',DATETIME() - 5)
		INSERT INTO csrdemo VALUES ('004','Eve','F',DATETIME() - 4)
		INSERT INTO csrdemo VALUES ('005','Lauren','F',DATETIME() - 3)
		INSERT INTO csrdemo VALUES ('009','Bob','M',DATETIME() - 2)
		INSERT INTO csrdemo VALUES ('006','Sharon','F',DATETIME() - 1)
		INSERT INTO csrdemo VALUES ('002','Bobby','X',DATETIME() - 7)
		
		LOCATE 

		CREATE CURSOR csrBooks (cCode C(3), cTitle C(25), tDTime T)

		CREATE CURSOR csrFees (cCode C(3), iFees I, tDTime T)
		
	ENDPROC
	
	PROCEDURE Init()
		DODEFAULT()
		
		BINDEVENT(This.pgfNames.Page2, "Click", This, "PTwoClick")
		BINDEVENT(This.pgfNames.Page3, "Click", This, "PThreeClick")
		BINDEVENT(This.pgfNames.Page4, "Click", This, "PFourClick")
		BINDEVENT(This.pgfNames.Page5, "Click", This, "PFiveClick")

	ENDPROC 
	
	PROCEDURE PTwoClick()
		LOCAL lcName as Character 
		
		WITH ThisForm.pgfNames
			.ActivePage = 2
			.Page2.grdNames.Visible = .T.
			
		ENDWITH 
		
		lcName = csrDemo.cName
		
		SELECT csrDemo.cCode, csrDemo.cName, NVL(iFees, 0), NVL(csrFees.tDTime, DATETIME(2000,01,01)) FROM csrDemo ;
			JOIN csrFees ON csrDemo.cCode = csrFees.cCode ;
			WHERE csrDemo.cName = lcName ;
			INTO CURSOR csrView
		
		IF _Tally > 0
			WITH ThisForm.pgfNames.Page2
				WITH .grdNames
					.ColumnCount = -1
					.RecordSource = "CSRVIEW"

					.Column1.Width = 60
					.Column2.Width = 120
					.Column3.Width = 60
					.Column4.Width = 120
				
					.Column1.Header1.Caption = "ID Code"
					.Column2.Header1.Caption = "Name"
					.Column3.Header1.Caption = "Fee"
					.Column4.Header1.Caption = "Date Time"

				ENDWITH 
				
				.Refresh()

			ENDWITH 
		ELSE
			WITH ThisForm.pgfNames.Page2
				.grdNames.Visible = .F.
				.Refresh()
				
			ENDWITH 		

			= MESSAGEBOX("No data found!", 64, "Paid Fees", 3000)
		
		ENDIF 
	ENDPROC
	
	PROCEDURE PThreeClick()
		WITH ThisForm.pgfNames
			.ActivePage = 3
			.Pages(3).grdNames.Visible = .F.
			.Pages(3).Refresh()
			
		ENDWITH 
		
		= MESSAGEBOX("Under construction!", 64, "Page 3 clicked", 3000)
		
	ENDPROC

	PROCEDURE PFourClick()
		LOCAL lcName as Character 
	
		WITH ThisForm.pgfNames
			.ActivePage = 4
			.Page4.grdNames.Visible = .T.
			
		ENDWITH 
		
		lcName = csrDemo.cName
		
		SELECT csrDemo.cCode, csrDemo.cName, NVL(cTitle, "N.N."), NVL(csrBooks.tDTime, DATETIME(2000,01,01)) FROM csrDemo ;
			JOIN csrBooks ON csrDemo.cCode = csrBooks.cCode ;
			WHERE csrDemo.cName = lcName ;
			INTO CURSOR csrView
			
		IF _Tally > 0
			
			WITH ThisForm.pgfNames.Page4
				WITH .grdNames
					.ColumnCount = -1
					.RecordSource = "CSRVIEW"

					.Column1.Width = 60
					.Column2.Width = 120
					.Column3.Width = 120
					.Column4.Width = 120
				
					.Column1.Header1.Caption = "ID Code"
					.Column2.Header1.Caption = "Name"
					.Column3.Header1.Caption = "Title"
					.Column4.Header1.Caption = "Date Time"
					
				ENDWITH 
				
				.Refresh()

			ENDWITH 	
		ELSE
			WITH ThisForm.pgfNames.Page4
				.grdNames.Visible = .F.
				.Refresh()
				
			ENDWITH 		

			= MESSAGEBOX("No data found!", 64, "Books", 3000)

		ENDIF 
	ENDPROC
			
	PROCEDURE PFiveClick()
		WITH ThisForm.pgfNames
			.ActivePage = 5
			.Pages(5).grdNames.Visible = .F.
			.Pages(5).Refresh()
			
		ENDWITH 

		= MESSAGEBOX("Under construction!", 64, "Page 5 clicked", 3000)
	
	ENDPROC

	
	PROCEDURE Destroy()
		This.cmdExit.Click()
	
	ENDPROC 
ENDDEFINE 

*********
DEFINE CLASS grdBase as Grid 
	Top = 12
	Left = 12
	Width = 480 - 24 - 24
	Height = 450 - 24 - 48 - 48
	BackColor = RGB(0, 246, 246)
	RowHeight = 21
	AllowRowSizing = .F.
	HeaderHeight = 21
	AllowHeaderSizing = .F.
	Anchor = 15
	ReadOnly = .T.
	DeleteMark = .F.

ENDDEFINE 

*********

DEFINE CLASS pagBase as Page

	FontBold = .T.
	Caption = "Students Record"
	Forecolor = RGB(128, 0, 0)

	ADD OBJECT grdStudents AS Grid WITH ;
		RecordSource = "csrDemo", ;
		ColumnCount = 3, ;
		Left = 12, ;
		Width = 480 - 48, ;
		Top = 54, ;
		Height = 450 - 24 - 42 - 24 - 24 - 54, ;
		Anchor = 15

		PROCEDURE grdStudents.Init()
			WITH This 
				.Column1.Header1.caption = "ID Number"
				.Column1.Header1.fontname = "Bernard MT Condensed"
				.Column1.Width = 120

				.Column2.Header1.caption = "Name of Student"
				.Column2.Header1.fontname = "Bernard MT Condensed"
				.Column2.Width = 150
			
				.Column3.Header1.caption = "Gender"
				.Column3.Header1.fontname = "Bernard MT Condensed"
				.Column3.Width = 60

			ENDWITH 
		ENDPROC
		
		PROCEDURE grdStudents.AfterRowColChange()
			LPARAMETERS nColIndex

			This.Parent.cmdAddData.Refresh()

		ENDPROC 

	ADD OBJECT cboSFBBU AS combobox WITH ; && 
		Height = 24, ;
		Left = 12, ;
		Top = 12, ;
		Width = 120, ;
		RowSourceType = 1, ;
		RowSource = "\<School Fees,\<Back,\<Books,\<Uniform"
		
		PROCEDURE cboSFBBU.click()
*!*			your code goes here - delete the code below

			WITH This.Parent.cmdAddData
				.Enabled = .T.
				.Refresh()

			ENDWITH 		
		ENDPROC
		
	ADD OBJECT cmdAddData AS CommandButton WITH ;
		TOP = 12, ;
		Left = 144, ;
		Height = 24, ;
		Autosize = .T., ;
		BackColor = RGB(180, 0, 0), ;
		ForeColor = RGB(252, 252, 252), ;
		Enabled = .F.
		
		PROCEDURE cmdAddData.Refresh()
			This.Caption = "Click to add data for " + ALLTRIM(csrDemo.cName) +" in table " + This.Parent.cboSFBBU.Value
			This.ToolTipText = IIF(This.Enabled, "Click to add data", "Select item from combobox to activate this button")

		ENDPROC 


		PROCEDURE cmdAddData.Click()
*!*				your code goes here - delete the code below
			
			DO CASE 
				CASE This.Parent.cboSFBBU.List(This.Parent.cboSFBBU.ListIndex,1) = "School Fees"
					
					INSERT INTO csrFees VALUES (csrDemo.cCode, INT(250 * RAND()), DATETIME())
					
					WITH This
						.Enabled = .F.
						.Refresh()
					ENDWITH 

				CASE This.Parent.cboSFBBU.List(This.Parent.cboSFBBU.ListIndex,1) = "Back"
					WAIT WINDOW + "You may add data for " + ALLTRIM(csrDemo.cName) + " into table [Back]" TIMEOUT 2

				CASE This.Parent.cboSFBBU.List(This.Parent.cboSFBBU.ListIndex,1) = "Books"

					INSERT INTO csrBooks VALUES (csrDemo.cCode, "BK" + SYS(2015), DATETIME())

					WITH This
						.Enabled = .F.
						.Refresh()
						
					ENDWITH 

				CASE This.Parent.cboSFBBU.List(This.Parent.cboSFBBU.ListIndex,1) = "Uniform"
					WAIT WINDOW + "You may add data for " + ALLTRIM(csrDemo.cName) + " into table [Uniforms]" TIMEOUT 2
					
				OTHERWISE 
					WAIT WINDOW + " No table selected! " TIMEOUT 5
				
			ENDCASE 
		ENDPROC 
ENDDEFINE
*********

hth

MarK
 
Hi Mark.... i am so overwhelmed with your so much help....I am so happy!! I'll study both and get some of it Mark..... thank you very much God Bless!!!![bigsmile][bigsmile]
 
Hi Mandy,

Thank you for the "laudatio". You may of course copy/paste as much code snippets as you like/need. Nevertheless I'd like to underline that this code was written under many assumptions: I don't know either the structure and number of tables you use nor the goals you aim to reach. I just read the code you published, took it up, made my guesses and tried to show you how you could - not necessarily have to - integrate it in a working application. The demo code works but it remains a demo with all its flaws!

It is up to you to sketch, draw and finetune your application, to define your tables and to do the appropriate coding. Have fun!

hth

MarK
 
Hi Mark... sorry i wasnt able to use some of your codes... so i have reviewed well my codes and took some of your corrections... I was able to get rid of the field phrase not found, unfortunately there two issues that came up....
1. The data(MyDataB) in oGrid1 does not load when i open the page
2. Table has no index order set error when i click the combobox.

I have a form which has 5 pages, all four pages are running well but the 5th page run with the two errors mentioned above. The codes are below... I want the Cursor to be loaded in oGrid1 when the page is selected so that MyDataB may be accesed in Text90 which is a combobox.... May i ask help again? Thanks and God Bless....

DEFINE CLASS mypage5 as Page

Picture = "C:\Program Files\SCMS Info Wave\Img\background3.jpg"
FontBold = .T.
Caption = "Students Record"
Forecolor = rgb(128,0,0)

ADD OBJECT oGrid1 AS Grid WITH ;
RecordSource="MyDataB", ;
columncount = 2,;
Width = 300, ;
Top = 50, ;
Height = 100, ;
FontSize = 10, ;
left = 400,;
Wordwrap = .t.

ADD OBJECT text90 AS COMBOBOX WITH ; && Name
RowSourceType = 6, RowSource = "MyDataB",;
columncount = 2,;
Height = 23, ;
Left = 305, ;
Top = 5, ;
Wordwrap = .t.,;
Width = 210

ADD OBJECT Text1 AS combobox WITH ; && Tbackaccount
Height = 32, ;
Left = 400, ;
Top = 337, ;
Width = 150,;
RowSourceType = 1, RowSource = "\<School Fees,\<Back,\<Books,\<Uniform,",;
decimals = 2,;
fontsize = 11

ADD OBJECT oButton2 AS CommandButton WITH ;
TOP = 380,;
Left = 600, ;
Height = 35, ;
Width = 100, ;
fontname = "BRITANNIC BOLD",;
FontSize = 14, ;
ForeColor = RGB(0,128,128),;
Caption = "OK"

PROCEDURE Load()

SELECT ALLTRIM(sname) + ", " + ALLTRIM(fname), idnum FROM SMS ORDER BY sname, fname INTO CURSOR MyDataB

ENDPROC

PROCEDURE oGrid1.init

SET PATH TO c:
SET TALK OFF
SET BELL OFF
SET CENTURY ON
SET CONFIRM OFF
SET SAFETY OFF
SET ECHO OFF
SET ESCAPE OFF
SET AUTOSAVE ON

SELECT 2
USE transaction EXCLUSIVE ALIAS trans
INDEX on idnum TO idnumx3

SELECT 1
USE SMS exclusive ALIAS TSULAT
INDEX ON IDNUM TO IDNUMX2

SET RELATION TO IDNUM INTO trans

this.parent.oGrid1.Column1.Width = 180

this.parent.oGrid1.Column1.Header1.caption = "Name of Student"
this.parent.oGrid1.Column1.Header1.fontname = "Bernard MT Condensed"
this.parent.oGrid1.Column1.Width = 150

this.parent.oGrid1.Column2.Header1.caption = "ID Number"
this.parent.oGrid1.Column2.Header1.fontname = "Bernard MT Condensed"
this.parent.oGrid1.Column2.Width = 90

SELECT ALLTRIM(sname) + ", " + ALLTRIM(fname), idnum FROM SMS ORDER BY sname, fname INTO CURSOR MyDataB

ENDPROC


PROCEDURE text90.click()

this.parent.oGrid1.RecordSource = SPACE(0)
SELECT ALLTRIM(sname) + ", "+ ALLTRIM(fname), idnum FROM sms ORDER BY sname INTO CURSOR MyDataB
this.parent.oGrid1.RecordSource = "MyDataB"


SEEK alltrim(MyDataB.idnum)

IF FOUND()

code code code...

Endif

ENDPROC

PROCEDURE oButton2.Click

SELECT 2

SEEK ALLTRIM(idnum)

for i=1 to 10

m.deyta = "P"+transform(m.i)

IF &deyta=0
replace &deyta with this.parent.text31.value
this.parent.oGrid1.refresh()
MESSAGEBOX("Payment Recorded to SCHOOL FEES!",0+64,"Students' Record 2021")
EXIT
ENDIF

IF i = 10
MESSAGEBOX("No more Field to record SCHOOL FEES transaction!",0+64,"Students' Record 2021")
ENDIF
NEXT

this.parent.Refresh()

ENDPROC


ENDDEFINE
 
Hi Mandy,

Did you consider all the advice the Tek-Tips community gave you? Did you run my Demo-code? Do you understand how it works? If you answer YES to all the question why are there still all the quirks in your code? Just to name a few:

Code:
ADD OBJECT text90 AS COMBOBOX WITH ; && Name
RowSourceType = 6, ;
[highlight #FCE94F]RowSource = "MyDataB",;[/highlight] && This does NOT work - you have to add the field names e.g. MyDataB.Field1, Field2 ... 
columncount = 2,;
Height = 23, ;
Left = 305, ;
Top = 5, ;
Wordwrap = .t.,;
Width = 210

Code:
PROCEDURE Load()

SELECT ALLTRIM(sname) + ", " + ALLTRIM(fname), idnum FROM SMS ORDER BY sname, fname INTO CURSOR MyDataB

ENDPROC

[highlight #FCE94F]A page does NOT have a load event/method - a form has one[/highlight]

Code:
SET PATH TO c:
SET TALK OFF
SET BELL OFF
SET CENTURY ON
SET CONFIRM OFF
SET SAFETY OFF
SET ECHO OFF
SET ESCAPE OFF
SET AUTOSAVE ON

[highlight #FCE94F]These settings should be set in the main program of your project - not the INIT of a page's grid
[/highlight]

Code:
SELECT 2
USE transaction EXCLUSIVE ALIAS trans
INDEX on idnum TO idnumx3

Why do you reindex the table each time you click on Page5? Why do you still Select 2?

Suggestion - if it's not possible to open the table while loading the form

[highlight #FCE94F]use transaction alias trans order idnum in 0 && that's a Zero
select trans[/highlight]

aso

You might consider me being a bit harsh - but unfortunately none of all the suggestions we have made (Tamar, Mike, me, a.o.) since April 12th (start of this thread) are reflected in your code.

hth

Mark

 
hi Mark... Ive tried everything and run all your suggestions... but i am confused on how to integrate my needs in the examples given... but i always read and study you examples Mark for future projects.... Im really sorry but im so confused... thank you so much Mark...God Bless
 
Hi Mandy

i am confused on how to integrate my needs in the examples given

That's NOT the way to go - its the opposite: you define your needs and you check/decide whether some snippets of code - as is or modified - fit in.

hth

MarK
 
Hi Mandy

Please find below the same code with some explanations

Code:
*!*	Explanations: 
*!*	Below I instantiate a form, show it and read the EVENTS triggered

PUBLIC go_Form

go_Form = NEWOBJECT("frmForm")
go_Form.Visible = .T.
go_Form.Show

READ Events

CLOSE ALL 
CLEAR ALL
RETURN 

*********

*!*	The frmForm class is defined

DEFINE CLASS frmForm As Form
	Width = 480
	MinWidth = 480
	MaxWidth = 510
	Height = 450
	MinHeight = 450
	AutoCenter = .T.
	Caption = "Students - Fees - Books"
	ShowTips = .T.
	Themes = .F.
	
*!*	I add a Pageframe to the form - it has 0 (zero) pages
	
	ADD OBJECT pgfNames as Pageframe WITH ;
		Top = 12, ;
		Left = 12, ;
		Height = 450 - 24 - 42 , ;
		Width = 480 - 24, ;
		Anchor = 15, ;
		PageCount = 0

*!*	Since the pageframe has no pages, I have to add some - the first one as an instance of the pagBase class (see below) 
*!*	and 4 (2 to 5) that are based on the VFP page class - this is done while the pageframe is INITiated
		
		PROCEDURE pgfNames.Init()
			LOCAL loPage as Object
			
			WITH This
				.NewObject("Page1","pagBase")
				.NewObject("Page2","Page")
				.NewObject("Page3","Page")
				.NewObject("Page4","Page")
				.NewObject("Page5","Page")

			ENDWITH 

*!*	I add captions to pages 2 to 5 - page one has its caption defined in its class - and add a grid based on the class grdBase on each page

			FOR i = 2 TO 5
				loPage = This.Pages(i)
				WITH loPage
					.Caption = ICASE(i = 2, "Fees", i = 3, "Back", i = 4, "Books", "Uniform")
					.NewObject("grdNames","grdBase")
					.grdNames.Visible = .F.

				ENDWITH 
			ENDFOR 
		ENDPROC 

*!*	I add an EXIT commandbutton to the form which closes it, clears the EVENTS and returns to the command right after READ EVENTS above		
	
	ADD OBJECT cmdExit As CommandButton WITH ;
	   	Width = 60, Height = 30, Left = 480 - 12 - 60, Top = 450 - 12 - 30, Caption = "Exit", Anchor = 12
    	
		PROCEDURE cmdExit.Click()
			ThisForm.Release
			CLEAR Events
		
		ENDPROC
		
*!*	I create three cursors in order to simulate tables
*!*	csrDemo (Students), csrFees (Fees) and csrBooks (Books) - they are normalized
*!*	csrDemo is fed with some data (students) 
*!*    csrBooks and csrFees are empty - they are fed by the user

	PROCEDURE Load()
	
		CREATE CURSOR csrdemo (cCode C(3), cName C(10), cGender C(1), tDTime T)
		
		INSERT INTO csrdemo VALUES ('001','Henry','M',DATETIME() - 6)
		INSERT INTO csrdemo VALUES ('011','Jenny','F',DATETIME() - 5)
		INSERT INTO csrdemo VALUES ('004','Eve','F',DATETIME() - 4)
		INSERT INTO csrdemo VALUES ('005','Lauren','F',DATETIME() - 3)
		INSERT INTO csrdemo VALUES ('009','Bob','M',DATETIME() - 2)
		INSERT INTO csrdemo VALUES ('006','Sharon','F',DATETIME() - 1)
		INSERT INTO csrdemo VALUES ('002','Bobby','X',DATETIME() - 7)
		
		LOCATE 

		CREATE CURSOR csrBooks (cCode C(3), cTitle C(25), tDTime T)

		CREATE CURSOR csrFees (cCode C(3), iFees I, tDTime T)
		
	ENDPROC
	
*!*	Since I am in progamming mode and do not have interactive access to the pages' click event 
*!*	I have to create four methods on the form level to simulate the pages' 2 to 5 click event
*!*	This is done while the form is INITiated

	PROCEDURE Init()
		DODEFAULT()
		
		BINDEVENT(This.pgfNames.Page2, "Click", This, "PTwoClick")
		BINDEVENT(This.pgfNames.Page3, "Click", This, "PThreeClick")
		BINDEVENT(This.pgfNames.Page4, "Click", This, "PFourClick")
		BINDEVENT(This.pgfNames.Page5, "Click", This, "PFiveClick")

	ENDPROC 

*!*	Now follows the code associated with the 4 methods: 
*!*	data is SELECTED from csrDemo and csrFees (PTwoClick) - from csrDemo and csrBooks (PFourClick); 
*!*	PThreeClick and PFiveClick just give visual clues that they are "alive"

	PROCEDURE PTwoClick()
		LOCAL lcName as Character 
		
		WITH ThisForm.pgfNames
			.ActivePage = 2
			.Page2.grdNames.Visible = .T.
			
		ENDWITH 
		
		lcName = csrDemo.cName
		
		SELECT csrDemo.cCode, csrDemo.cName, NVL(iFees, 0), NVL(csrFees.tDTime, DATETIME(2000,01,01)) FROM csrDemo ;
			JOIN csrFees ON csrDemo.cCode = csrFees.cCode ;
			WHERE csrDemo.cName = lcName ;
			INTO CURSOR csrView
		
		IF _Tally > 0
			WITH ThisForm.pgfNames.Page2
				WITH .grdNames
					.ColumnCount = -1
					.RecordSource = "CSRVIEW"

					.Column1.Width = 60
					.Column2.Width = 120
					.Column3.Width = 60
					.Column4.Width = 120
				
					.Column1.Header1.Caption = "ID Code"
					.Column2.Header1.Caption = "Name"
					.Column3.Header1.Caption = "Fee"
					.Column4.Header1.Caption = "Date Time"

				ENDWITH 
				
				.Refresh()

			ENDWITH 
		ELSE
			WITH ThisForm.pgfNames.Page2
				.grdNames.Visible = .F.
				.Refresh()
				
			ENDWITH 		

			= MESSAGEBOX("No data found!", 64, "Paid Fees", 3000)
		
		ENDIF 
	ENDPROC
	
	PROCEDURE PThreeClick()
		WITH ThisForm.pgfNames
			.ActivePage = 3
			.Pages(3).grdNames.Visible = .F.
			.Pages(3).Refresh()
			
		ENDWITH 
		
		= MESSAGEBOX("Under construction!", 64, "Page 3 clicked", 3000)
		
	ENDPROC

	PROCEDURE PFourClick()
		LOCAL lcName as Character 
	
		WITH ThisForm.pgfNames
			.ActivePage = 4
			.Page4.grdNames.Visible = .T.
			
		ENDWITH 
		
		lcName = csrDemo.cName
		
		SELECT csrDemo.cCode, csrDemo.cName, NVL(cTitle, "N.N."), NVL(csrBooks.tDTime, DATETIME(2000,01,01)) FROM csrDemo ;
			JOIN csrBooks ON csrDemo.cCode = csrBooks.cCode ;
			WHERE csrDemo.cName = lcName ;
			INTO CURSOR csrView
			
		IF _Tally > 0
			
			WITH ThisForm.pgfNames.Page4
				WITH .grdNames
					.ColumnCount = -1
					.RecordSource = "CSRVIEW"

					.Column1.Width = 60
					.Column2.Width = 120
					.Column3.Width = 120
					.Column4.Width = 120
				
					.Column1.Header1.Caption = "ID Code"
					.Column2.Header1.Caption = "Name"
					.Column3.Header1.Caption = "Title"
					.Column4.Header1.Caption = "Date Time"
					
				ENDWITH 
				
				.Refresh()

			ENDWITH 	
		ELSE
			WITH ThisForm.pgfNames.Page4
				.grdNames.Visible = .F.
				.Refresh()
				
			ENDWITH 		

			= MESSAGEBOX("No data found!", 64, "Books", 3000)

		ENDIF 
	ENDPROC
			
	PROCEDURE PFiveClick()
		WITH ThisForm.pgfNames
			.ActivePage = 5
			.Pages(5).grdNames.Visible = .F.
			.Pages(5).Refresh()
			
		ENDWITH 

		= MESSAGEBOX("Under construction!", 64, "Page 5 clicked", 3000)
	
	ENDPROC

	
	PROCEDURE Destroy()
		This.cmdExit.Click()
	
	ENDPROC 
ENDDEFINE 

*********

*!*	A grid class is defined; it is instantiated on pages 2 to 5 of the pageframe

DEFINE CLASS grdBase as Grid 
	Top = 12
	Left = 12
	Width = 480 - 24 - 24
	Height = 450 - 24 - 48 - 48
	BackColor = RGB(0, 246, 246)
	RowHeight = 21
	AllowRowSizing = .F.
	HeaderHeight = 21
	AllowHeaderSizing = .F.
	Anchor = 15
	ReadOnly = .T.
	DeleteMark = .F.

ENDDEFINE 

*********

*!*	pagBase is defined; it is instantiated as Page1 of the pageframe above

DEFINE CLASS pagBase as Page

	FontBold = .T.
	Caption = "Students Record"
	Forecolor = RGB(128, 0, 0)
	
*!*	A grid is added to the class pagBase and has csrDemo as RecordSource

	ADD OBJECT grdStudents AS Grid WITH ;
		RecordSource = "csrDemo", ;
		ColumnCount = 3, ;
		Left = 12, ;
		Width = 480 - 48, ;
		Top = 54, ;
		Height = 450 - 24 - 42 - 24 - 24 - 54, ;
		Anchor = 15

		PROCEDURE grdStudents.Init()
			WITH This 
				.Column1.Header1.caption = "ID Number"
				.Column1.Header1.fontname = "Bernard MT Condensed"
				.Column1.Width = 120

				.Column2.Header1.caption = "Name of Student"
				.Column2.Header1.fontname = "Bernard MT Condensed"
				.Column2.Width = 150
			
				.Column3.Header1.caption = "Gender"
				.Column3.Header1.fontname = "Bernard MT Condensed"
				.Column3.Width = 60

			ENDWITH 
		ENDPROC

*!*	You either click on the grid to select a student or you can move through the records - each time the commandbutton's (cmdAddData) caption is refreshed
		
		PROCEDURE grdStudents.AfterRowColChange()
			LPARAMETERS nColIndex

			This.Parent.cmdAddData.Refresh()

		ENDPROC 

*!*	A combox with fixed values is added to the class pagBase

	ADD OBJECT cboSFBBU AS combobox WITH ; && 
		Height = 24, ;
		Left = 12, ;
		Top = 12, ;
		Width = 120, ;
		RowSourceType = 1, ;
		RowSource = "\<School Fees,\<Back,\<Books,\<Uniform"
		
*!*	You click on an item of the combox to enable and refresh the cmdAddData

		PROCEDURE cboSFBBU.click()

			WITH This.Parent.cmdAddData
				.Enabled = .T.
				.Refresh()

			ENDWITH 		
		ENDPROC

*!*	The commandbutton cmdAddData is added to the class pagBase
		
	ADD OBJECT cmdAddData AS CommandButton WITH ;
		TOP = 12, ;
		Left = 144, ;
		Height = 24, ;
		Autosize = .T., ;
		BackColor = RGB(180, 0, 0), ;
		ForeColor = RGB(252, 252, 252), ;
		Enabled = .F.
		
*!*	The caption of cmdAddData is defined awa its ToolTipText

		PROCEDURE cmdAddData.Refresh()
			This.Caption = "Click to add data for " + ALLTRIM(csrDemo.cName) +" in table " + This.Parent.cboSFBBU.Value
			This.ToolTipText = IIF(This.Enabled, "Click to add data", "Select item from combobox to activate this button")

		ENDPROC 

*!*	When clicking cmdAddData Data is added to the cursors depending on the item choosen from the combox and the selected student

		PROCEDURE cmdAddData.Click()

			DO CASE 
				CASE This.Parent.cboSFBBU.List(This.Parent.cboSFBBU.ListIndex,1) = "School Fees"
					
					INSERT INTO csrFees VALUES (csrDemo.cCode, INT(250 * RAND()), DATETIME())
					
					WITH This
						.Enabled = .F.
						.Refresh()
					ENDWITH 

				CASE This.Parent.cboSFBBU.List(This.Parent.cboSFBBU.ListIndex,1) = "Back"
					WAIT WINDOW + "You may add data for " + ALLTRIM(csrDemo.cName) + " into table [Back]" TIMEOUT 2

				CASE This.Parent.cboSFBBU.List(This.Parent.cboSFBBU.ListIndex,1) = "Books"

					INSERT INTO csrBooks VALUES (csrDemo.cCode, "BK" + SYS(2015), DATETIME())

					WITH This
						.Enabled = .F.
						.Refresh()
						
					ENDWITH 

				CASE This.Parent.cboSFBBU.List(This.Parent.cboSFBBU.ListIndex,1) = "Uniform"
					WAIT WINDOW + "You may add data for " + ALLTRIM(csrDemo.cName) + " into table [Uniforms]" TIMEOUT 2
					
				OTHERWISE 
					WAIT WINDOW + " No table selected! " TIMEOUT 5
				
			ENDCASE 
		ENDPROC 
ENDDEFINE
*********

hh

MarK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top