Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Writing to a table from a command button
Message
 
À
16/01/2006 12:31:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01087232
Message ID:
01087238
Vues:
12
>Using Cursorsetprop() and tableupdate I have not been able to figure out how to update a table with a preloaded value under a command button. I want to have a selection of sequencial dates, each with it's own command button. A user clicks and the date is written to a table. It seems as if it is such an easy task and yet I have had no success over the weekend. How about a hint?

Something like this?
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


	**************************************************
*-- Form:         form1 (d:\works\electrowithtraff\test.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   01/16/06 07:51:06 PM
*
DEFINE CLASS form1 AS form


	Top = 0
	Left = 0
	Height = 163
	Width = 188
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 5, ;
		Left = 7, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command1"


	ADD OBJECT command2 AS commandbutton WITH ;
		Top = 33, ;
		Left = 8, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command2"


	ADD OBJECT command3 AS commandbutton WITH ;
		Top = 63, ;
		Left = 8, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command3"


	ADD OBJECT command4 AS commandbutton WITH ;
		Top = 91, ;
		Left = 7, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command4"


	ADD OBJECT command5 AS commandbutton WITH ;
		Top = 5, ;
		Left = 95, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command5"


	ADD OBJECT command6 AS commandbutton WITH ;
		Top = 33, ;
		Left = 96, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command6"


	ADD OBJECT command7 AS commandbutton WITH ;
		Top = 63, ;
		Left = 96, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command7"


	ADD OBJECT command8 AS commandbutton WITH ;
		Top = 91, ;
		Left = 95, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command8"


	ADD OBJECT check1 AS checkbox WITH ;
		Top = 135, ;
		Left = 14, ;
		Height = 17, ;
		Width = 162, ;
		Caption = "Insert dates", ;
		Value = .F., ;
		Name = "Check1"


	PROCEDURE udatetable
		LPARAMETERS loButton
		LOCAL ldDate
		m.ldDate = DATE(VAL(LEFT(loButton.Tag,4)),VAL(SUBSTR(loButton.Tag,5,2)),VAL(RIGHT(loButton.Tag,2)))
		IF thisform.Check1.Value && Insert recod
		   INSERT INTO tblTest VALUES (m.ldDate)
		ELSE
		   UPDATE tblTest SET TestDate = m.ldDate
		ENDIF
		TABLEUPDATE(1,.t.,[tblTest])
	ENDPROC


	PROCEDURE Init
		SELECT tblTest
		CURSORSETPROP("Buffering",5,"tblTest")
		APPEND BLANK && Just to have one empty record
		FOR lnFor = 1 TO 8
		    WITH EVALUATE([thisform.Command]+TRANSFORM(lnFor))
		         .Caption = DTOC(DATE()+lnFor)
		         .Tag     = DTOS(DATE()+lnFor)
		    ENDWITH
		NEXT
	ENDPROC


	PROCEDURE Load
		CREATE TABLE tblTest (TestDate D)
	ENDPROC


	PROCEDURE command1.Click
		thisform.UdateTable(this)
	ENDPROC


	PROCEDURE command2.Click
		thisform.UdateTable(this)
	ENDPROC


	PROCEDURE command3.Click
		thisform.UdateTable(this)
	ENDPROC


	PROCEDURE command4.Click
		thisform.UdateTable(this)
	ENDPROC


	PROCEDURE command5.Click
		thisform.UdateTable(this)
	ENDPROC


	PROCEDURE command6.Click
		thisform.UdateTable(this)
	ENDPROC


	PROCEDURE command7.Click
		thisform.UdateTable(this)
	ENDPROC


	PROCEDURE command8.Click
		thisform.UdateTable(this)
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform