PUBLIC go_Form
go_Form = CreateObject("frmForm")
go_Form.Visible = .T.
go_Form.Show
READ Events
CLOSE ALL
CLEAR ALL
*****
DEFINE CLASS frmForm As Form
Width = 570
Height = 360
MinWidth = This.Width
MinHeight = This.Height
AutoCenter = .T.
Themes = .F.
ADD OBJECT lblTable as Label WITH ;
Left = 18, Top = 18, Caption = "Data in Table", FontItalic = .T., FontBold = .T.
ADD OBJECT lblName as Label WITH ;
Left = 126, Top = 18, Caption = "Enter name :"
ADD OBJECT txtName as TextBox WITH ;
Left = 210, Top = 15, Value = ""
ADD OBJECT cmdRequery as CommandButton WITH ;
Left = 330, Top = 15, Height = 24, Caption = "Requery view"
PROCEDURE cmdRequery.Click()
IF EMPTY(ALLTRIM(ThisForm.txtName.Value))
= MESSAGEBOX("Please enter name", 48, "Names")
ELSE
REQUERY("vueNames")
ENDIF
ThisForm.Refresh()
ENDPROC
ADD OBJECT cmdSave as CommandButton WITH ;
Left = 450, Top = 15, Height = 24, Caption = "Save to table"
PROCEDURE cmdSave.Click()
= TABLEUPDATE(0, .T., "vueNames")
ENDPROC
ADD OBJECT lblView as Label WITH ;
Left = 18, Top = 180, Caption = "Data in View", FontItalic = .T., FontBold = .T., Anchor = 90
Add Object grdATM as Grid WITH ;
ReadOnly = .T., ;
Top = 48, ;
Left = 18, ;
Height = 120, ;
Width = ThisForm.Width - 36, ;
RowHeight = 24, ;
AllowRowSizing = .F., ;
HeaderHeight = 21, ;
AllowHeaderSizing = .F., ;
DeleteMark = .F., ;
Anchor = 75, ;
Visible = .T., ;
ColumnCount = -1, ;
RecordSource = "tblNames"
PROCEDURE grdATM.Init()
WITH This
.Column1.Header1.Caption = "Auto"
.Column1.Header1.FontBold = .T.
.Column1.Width = 60
.Column2.Header1.Caption = "Name"
.Column2.Header1.FontBold = .T.
.Column2.Width = 120
.Column3.Header1.Caption = "Street"
.Column3.Header1.FontBold = .T.
.Column3.Width = 150
.Column4.Header1.Caption = "City"
.Column4.Header1.FontBold = .T.
.Column4.Width = 150
.Column5.Header1.Caption = "ZipCode"
.Column5.Header1.FontBold = .T.
.Column5.Width = 150
ENDWITH
ENDPROC
Add Object grdATMVUE as Grid with;
Top = 204, ;
Left = 18, ;
Height = 120, ;
Width = ThisForm.Width - 36, ;
RowHeight = 24, ;
AllowRowSizing = .F., ;
HeaderHeight = 21, ;
AllowHeaderSizing = .F., ;
DeleteMark = .F., ;
Anchor = 30, ;
Visible = .T., ;
ColumnCount = -1, ;
RecordSource = "vueNames"
PROCEDURE grdATMVUE.Init()
WITH This
.Column1.Header1.Caption = "Auto"
.Column1.Header1.FontBold = .T.
.Column1.Width = 60
.Column1.ReadOnly = .T.
.Column2.Header1.Caption = "Name"
.Column2.Header1.FontBold = .T.
.Column2.Width = 120
.Column3.Header1.Caption = "Street"
.Column3.Header1.FontBold = .T.
.Column3.Width = 150
.Column4.Header1.Caption = "City"
.Column4.Header1.FontBold = .T.
.Column4.Width = 150
.Column5.Header1.Caption = "ZipCode"
.Column5.Header1.FontBold = .T.
.Column5.Width = 150
ENDWITH
ENDPROC
PROCEDURE Load()
IF FILE("ATMOS.DBC")
OPEN DATABASE ATMOS
ELSE
CREATE DATABASE "ATMOS"
CREATE TABLE "tblNames" (iAutoInc i AUTOINC NEXTVALUE 100, cName C(20), cStreet C(20), cCity C(20), cZipCode C(20))
INSERT INTO tblNames (cName, cStreet, cCity, cZipCode) VALUES ("Winston Smith","123 Anywhere St","Chicago","60601")
INSERT INTO tblNames (cName, cStreet, cCity, cZipCode) VALUES ("Andrea Lopez","235 N Ave","Lawrence","08648")
INSERT INTO tblNames (cName, cStreet, cCity, cZipCode) VALUES ("Sandra Johnson","2500 8th St","Los Angeles","90061")
INSERT INTO tblNames (cName, cStreet, cCity, cZipCode) VALUES ("Kate Wilson","987 M Blvd","Tarzana","91356")
INSERT INTO tblNames (cName, cStreet, cCity, cZipCode) VALUES ("Kate Smith","87 Santa M Blvd","Santa Barbara","91358")
INSERT INTO tblNames (cName, cStreet, cCity, cZipCode) VALUES ("Jim Monterrey","8715 Santa Monica","Santa Barbara","91358")
INSERT INTO tblNames (cName, cStreet, cCity, cZipCode) VALUES ("Winston Smith","123 Anywhere St","Eau Claire","20601")
INSERT INTO tblNames (cName, cStreet, cCity, cZipCode) VALUES ("Andrea Lopez","235 N Ave","Toronto","28648")
INSERT INTO tblNames (cName, cStreet, cCity, cZipCode) VALUES ("Sandra Johnson","2500 8th St","Los Alamos","20061")
INSERT INTO tblNames (cName, cStreet, cCity, cZipCode) VALUES ("Kate Wilson","987 M Blvd","Carlson","21356")
INSERT INTO tblNames (cName, cStreet, cCity, cZipCode) VALUES ("Kate Smith","87 Santa M Blvd","Santa Ines","21358")
INSERT INTO tblNames (cName, cStreet, cCity, cZipCode) VALUES ("Jim Monterrey","8715 Santa Monica","Santa Ines","21358")
LOCATE
CREATE SQL VIEW vueNames AS ;
Select * from tblNames where cName = ?ALLTRIM(ThisForm.txtName.Value)
DBSETPROP('vueNames', 'View', 'Tables', 'tblNames')
*!* Set the tables to be updated.
DBSETPROP('vueNames.iAutoInc', 'Field', 'UpdateName', 'tblNames.iAutoInc')
DBSETPROP('vueNames.cName', 'Field', 'UpdateName', 'tblNames.cName')
DBSETPROP('vueNames.cStreet', 'Field', 'UpdateName', 'tblNames.cStreet')
DBSETPROP('vueNames.cCity', 'Field', 'UpdateName', 'tblNames.cCity')
DBSETPROP('vueNames.cZipCode', 'Field', 'UpdateName', 'tblNames.cZipCode')
** Set update names.
DBSETPROP('vueNames.iAutoInc', 'Field', 'KeyField', .T.)
*!* Set a single-field unique key for the tblNames table.
DBSETPROP('vueNames.cName', 'Field', 'Updatable', .T.)
DBSETPROP('vueNames.cStreet', 'Field', 'Updatable', .T.)
DBSETPROP('vueNames.cCity', 'Field', 'Updatable', .T.)
DBSETPROP('vueNames.cZipCode', 'Field', 'Updatable', .T.)
*!* Set the updatable fields. Typically, key fields are not updatable.
DBSETPROP('vueNames', 'View', 'SendUpdates', .T.)
*!* Activate the update functionality.
ENDIF
IF USED("tblNames")
SELECT tblNames
ELSE
USE tblNames IN 0
ENDIF
IF USED("vueNames")
SELECT vueNames
ELSE
USE vueNames IN 0
ENDIF
ENDPROC
PROCEDURE Destroy()
CLEAR Events
ThisForm.Release
ENDPROC
ENDDEFINE
*****