This example applies to the knowledge of the Between...and clause in the SELECT statement, referring to the SELECT statement: Select SQL command or the SQL language tutorial.
This example runs the following diagram:
This example uses the "Data 1" database "People information table", about the database is already looking at the case of VFP: sample database is given in the article, no longer detailed here.
The production steps are as follows:
Create a new form, set its Caption property value to "example of a query for a time period", set the Width property value to the 290,height property value set to the 195,autocenter property value set to. T, and save it as an example of a query to a time period. Scx ".
Two, add two label controls to the form, set their Caption property values to "date of birth" and "and", set the ForeColor property value to "0,0,255", and line the two label controls into one line.
Third, add two text box controls to the form, adjust their positions, leave the two label controls Spaced, and set their Value property values to "{}" (for the properties of the text box control refer to: TextBox control).
Add a Grid control below the text box and label control and set its Width property value to the 290,height property value of 110.
Five, add two command buttons Command1 and Command2 below the grid control, and set their Caption property values to query and exit respectively.
Adjust the position of the controls on the form appropriately, and the adjusted form Designer is shown below:
Vii. Add event code:
(i) Unload event for the form: close data
(ii) The Init event of the form:
Use person information table with THISFORM.GRID1. Recordsource= Personnel Information table. Deletemark=.f.
. visible=.t.
. readonly=.t. . Columncount=8. column1.header1.caption= "Number". Column1.header1.backcolor=rgb (255,255,190). Column2.header1.backcolor=rgb (255,255,190). column2.header1.caption= "Name". Column3.header1.backcolor=rgb (255,255,190). Column3.header1.caption= "department". column4.header1.caption= "Gender". Column4.header1.backcolor=rgb (255,255,190). Column5.header1.caption= "Education". Column5.header1.backcolor=rgb (255,255,190). Column6.header1.caption= "Basic Salary". Column6.header1.backcolor=rgb (255,255,190). column7.header1.caption= "Home Address". Column7.header1.backcolor=rgb (255,255,190). column8.header1.caption= "Date of birth". Column8.header1.backcolor=rgb (255,255,190). Column1.width=40. Column2.width=50. Column3.width=50. Column4.width=30. Column5.width=60. Column6.width=60. Column7.width=60. column8.width=60 Endwith Thisform.grid1.Setall ("Dynamicbackcolor "," RGB (224,225,255) "," Column ")
(c) Click event for Query button (Command1):
If thisform.text1.value={} messagebox ("Please fill in the Starting date of birth", 16, "system hint") Thisform.text1.setfocus else if thisform.text2.value={
MessageBox ("Please fill in the terminated birth date", 16, "System Prompt") Thisform.text2.setfocus else Select * from personnel information table where birth date;
Between Thisform.text1.value and Thisform.text2.value;
into cursor temporary personnel information table with THISFORM.GRID1. width=450. height=130. recordsource= "Temporary personnel information table"
. deletemark=.f.
. visible=.t. . Columncount=8. column1.header1.caption= "Number". Column1.header1.backcolor=rgb (255,255,190). Column2.header1.backcolor=rgb (255,255,190). column2.header1.caption= "Name". Column3.header1.backcolor=rgb (255,255,190). Column3.header1.caption= "department". column4.header1.caption= "Gender". Column4.header1.backcolor=rgb (255,255,190). Column5.header1.caption= "Education". Column5.header1.backcolor=rgb (255,255,190). Column6.header1.caption= "Basic Salary". Column6.header1.backcolor=rGB (255,255,190). column7.header1.caption= "Home Address". Column7.header1.backcolor=rgb (255,255,190). column8.header1.caption= "Date of birth". Column8.header1.backcolor=rgb (255,255,190). Column1.width=40. Column2.width=50. Column3.width=50. Column4.width=30. Column5.width=60. Column6.width=60. Column7.width=60. column8.width=60 endwith thisform.grid1.Setall ("Dynamicbackcolor", "RGB (224,225,255)", "Column") endif endif
(iv) Click event for Exit button (Command2): Thisform.release
Eight, run "to the time period query example." Scx ".
Resources:
The basic course of VFP: http://bianceng.cnhttp://www.bianceng.cn/vfpjc/index0.htm
VFP Primary Course: http://bianceng.cnhttp://www.bianceng.cn/cc/index.htm
VFP Intermediate Course: http://bianceng.cnhttp://www.bianceng.cn/mcc/mcc.htm
VFP Advanced Course: http://bianceng.cnhttp://www.bianceng.cn/hcc/hcc.htm
VFP Network Development: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpwlkf.htm
VFP Call API function: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpapi.htm
VFP Report Print: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpreport.htm
VFP Common technique: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpcyjs.htm
VFP Experience Summary: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpjyhz.htm
VFP Control use: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpkjsy.htm
VFP Data processing: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpsjcl.htm
This example code is debugged in the win2003+vfp6.0 environment.
See the full set of "rookie also learn VFP" tutorial