Search This Blog

Release Block User Code

In any login code, aside from status login, logout, I also made use of block. A user has a status of block if his username and password dis not match thrice in a row. This will help in the security of accessing the program.

PUBLIC pBlockUser
IF !EMPTY(THISFORM.Text2.Value)
IF THISFORM.Text4.Value = "BLOCK"
pBlockUser = THISFORM.Text3.Value
lAnswer = MESSAGEBOX("Do you want to release "+ALLTRIM(pBlockUser)+"?", 4, "Confirmation")
IF lAnswer = 6
SELECT SviewAccess
LOCATE FOR IdNum = THISFORM.Text2.Value
IF FOUND()
REPLACE AccessStatus WITH "LOGOUT"
=MESSAGEBOX("Successfully release "+ALLTRIM(pBlockUser)+" .", "Confirmation")
THISFORM.Grid1.REFRESH
ENDIF
ENDIF
ELSE
=MESSAGEBOX("Select a Block User.", "Confirmation")
ENDIF
ELSE
=MESSAGEBOX("Select User.", "Confirmation")
ENDIF

Balance Code

This code will check if textbox 1 is equal to textbox 2. If the two quantities is not equal a messagebox 'Not balance.' will appear but continue printing if balance at all.

IF !EMPTY(THISFORM.Text3.Value)
IF (THISFORM.Text1.Value) = (THISFORM.Text2.Value)
REPORT FORM "C:\GenLed\Reports\ReportJournalEntry" TO PRINTER PROMPT NODIALOG PREVIEW
THISFORM.Refresh()
ELSE
=MESSAGEBOX("Not balance.", "Confirmation")
ENDIF
ELSE
=MESSAGEBOX("Choose Journal Entry.", "Confirmation")
ENDIF

Table Update Code

Sample of table update implemented in replace:

SELECT SviewAccountList
lBranches = pBranchName
=REQUERY("SviewAccountList")
LOCATE FOR (IdNum) = (THISFORM.Text34.Value)
IF FOUND()
REPLACE TotalDebit WITH THISFORM.TEXT15.Value
REPLACE TotalCredit WITH THISFORM.TEXT18.Value
REPLACE EndingBalance WITH THISFORM.TEXT26.Value
REPLACE Lines WITH "POST"
REPLACE LDate WITH DATE()
=TABLEUPDATE(.T.)
ENDIF

Do Case Code

DO CASE
CASE THISFORM.Text33.VALUE = "1"
THISFORM.Text22.Value = "ASSET"
THISFORM.Text15.Value = THISFORM.Text13.Value + THISFORM.Text10.Value
THISFORM.Text18.Value = THISFORM.Text14.Value + THISFORM.Text11.Value
THISFORM.Text25.Value = THISFORM.Text23.Value + THISFORM.Text10.Value - THISFORM.Text11.Value
THISFORM.Text26.Value = THISFORM.Text24.Value + THISFORM.Text10.Value - THISFORM.Text11.Value
CASE THISFORM.Text33.VALUE = "2"
THISFORM.Text22.Value = "LIABILITY"
THISFORM.Text15.Value = THISFORM.Text13.Value + THISFORM.Text10.Value
THISFORM.Text18.Value = THISFORM.Text14.Value + THISFORM.Text11.Value
THISFORM.Text25.Value = THISFORM.Text23.Value - THISFORM.Text10.Value + THISFORM.Text11.Value
THISFORM.Text26.Value = THISFORM.Text24.Value - THISFORM.Text10.Value + THISFORM.Text11.Value
CASE THISFORM.Text33.VALUE = "3"
THISFORM.Text22.Value = "CAPITAL"
THISFORM.Text15.Value = THISFORM.Text13.Value + THISFORM.Text10.Value
THISFORM.Text18.Value = THISFORM.Text14.Value + THISFORM.Text11.Value
THISFORM.Text25.Value = THISFORM.Text23.Value - THISFORM.Text10.Value + THISFORM.Text11.Value
THISFORM.Text26.Value = THISFORM.Text24.Value - THISFORM.Text10.Value + THISFORM.Text11.Value
CASE THISFORM.Text33.VALUE = "4"
THISFORM.Text22.Value = "OPN"
THISFORM.Text15.Value = THISFORM.Text13.Value + THISFORM.Text10.Value
THISFORM.Text18.Value = THISFORM.Text14.Value + THISFORM.Text11.Value
THISFORM.Text25.Value = THISFORM.Text23.Value + THISFORM.Text10.Value - THISFORM.Text11.Value
THISFORM.Text26.Value = THISFORM.Text24.Value + THISFORM.Text10.Value - THISFORM.Text11.Value
CASE THISFORM.Text33.VALUE = "5"
THISFORM.Text22.Value = "INCOME"
THISFORM.Text15.Value = THISFORM.Text13.Value + THISFORM.Text10.Value
THISFORM.Text18.Value = THISFORM.Text14.Value + THISFORM.Text11.Value
THISFORM.Text25.Value = THISFORM.Text23.Value - THISFORM.Text10.Value + THISFORM.Text11.Value
THISFORM.Text26.Value = THISFORM.Text24.Value - THISFORM.Text10.Value + THISFORM.Text11.Value
CASE THISFORM.Text33.VALUE = "6"
THISFORM.Text22.Value = "EXPENSE"
THISFORM.Text15.Value = THISFORM.Text13.Value + THISFORM.Text10.Value
THISFORM.Text18.Value = THISFORM.Text14.Value + THISFORM.Text11.Value
THISFORM.Text25.Value = THISFORM.Text23.Value + THISFORM.Text10.Value - THISFORM.Text11.Value
THISFORM.Text26.Value = THISFORM.Text24.Value + THISFORM.Text10.Value - THISFORM.Text11.Value
ENDCASE

Counter Code

PUBLIC pEndBegin, pidnum
SELECT SviewAccountList
lBranches = pBranchName
=REQUERY("SviewAccountList")
GO TOP
lCounter = RECCOUNT()
SCAN
pEndBegin = SviewAccountList.EndingBalance
pIdNum = SviewAccountList.IdNum
SELECT SviewAccountList
LOCATE FOR IdNum = pIdNum
IF FOUND()
REPLACE BeginBal WITH pEndBegin
REPLACE tagsked WITH CMONTH(DATE())
ENDIF
ENDSCAN

Avoid Backspace on Previous Textbox Code

Have you ever experience that when you press backspace and if the character on current textbox is fully deleted that it goes on previous textbox?

Try to put the following code on keypress of a textbox

IF EMPTY(THIS.SelStart)
IF NKEYCODE=127
KEYBOARD '{DNARROW}'
ENDIF
ENDIF

Login Form


Fill-out the Username, Password and Branch field and click the OK button to continue. The following spaces should be filled with correct Username, Password and desired Branch to continue. Selected branch will give you information and data for that branch only.

Activity Log in FoxPro

This is my first sample form of Activity Log in FoxPro. My current project which is a General ledger required me to have Activity Log. It is easy to make a log but requires me to update the table from different form and command such as login, logout, add, edit, delete and post. But will be handy of traceability purpose.

Trial Balance in FoxPro

Sample form of Trial Balance in Journal Entries or General Ledger. General Ledger is one of the famous system that is being develop or being automate for faster, easy processing.

Changing Signatory Code

Most of the program I made out of FoxPro required signatory. This signatory can be achieve upon login into the system.

SELECT Signatory
LOCATE FOR signnum = 1
IF FOUND()
REPLACE SignName WITH THISFORM.Text1.Value
REPLACE SignPostion WITH THISFORM.Text2.Value
ENDIF
LOCATE FOR signnum = 2
IF FOUND()
REPLACE SignName WITH THISFORM.Text3.Value
REPLACE SignPostion WITH THISFORM.Text4.Value
ENDIF
LOCATE FOR signnum = 3
IF FOUND()
REPLACE SignName WITH THISFORM.Text5.Value
REPLACE SignPostion WITH THISFORM.Text6.Value
ENDIF
=MESSAGEBOX("Signatories successfully save.")

Changing Image or Picture of a Button

You can definitely change the picture of your bitton upon clicking, try these codes and play with the images. But first you have to prepare the image in JPEG.

IF THIS.Picture = "c:\images\edit.jpg"
THIS.Picture = "c:\images\save.jpg"
THISFORM.cmdClose.Picture = "c:\images\cancel.jpg"
ELSE
IF THISFORM.Combo1.Value = 'PESO'
lAnswer = MESSAGEBOX("Save changes?", 4, "Confirmation")
IF lAnswer = 6
THISFORM.cmdClose.Picture = "c:\images\close.jpg"
THISFORM.cmdEdit.Picture = "c:\images\edit.jpg"
ENDIF
ELSE THISFORM.COMBO1.Value = 'DOLLAR'
lAnswer = MESSAGEBOX("Save changes?", 4, "Confirmation")
IF lAnswer = 6
THISFORM.cmdClose.Picture = "c:\images\close.jpg"
THISFORM.cmdEdit.Picture = "c:\images\edit.jpg"
ENDIF
ENDIF
ENDIF

Determining First Character

If you wwould like to determine the first character or first three characters etc of your textbox, you can use below foxpro codes:

THISFORM.Text1.VALUE = LEFT(TRANS(THISFORM.Text2.Value),1)

Delete Data in a Table Code

Deleting data from the local table.

SET EXCLUSIVE ON
USE "C:\EMPLOYEE\DATA\EmployeeList"
DELETE ALL
PACK

Day Month Year Code

THISFORM.TEXT1.VALUE = DAY(DATE())
THISFORM.TEXT2.VALUE = CMONTH(DATE())
THISFORM.TEXT3.VALUE = YEAR(DATE())

Main Program

SET CLASSLIB TO C:\GenLed\Classlib\frame
SET CLASSLIB TO C:\GenLed\Classlib\basectrl ADDITIVE
SET CLASSLIB TO C:\GenLed\Classlib\DeBrief
_screen.picture = "C:\GenLed\Images\background.bmp"

SET CENTURY ON
SET CENTURY TO 19 ROLLOVER 60
SET EXCLUSIVE OFF

RUN NumToWords

DO FORM "C:\GenLed\Forms\Login"

ON SHUTDOWN QUIT
MainApp = CREATEOBJECT("DEBRIEF", "FMLFC GENLED - Accounting Systematic Tool")
MainApp.ReadEvents()

SET CLASSLIB TO
RETURN

Log Out Code

PUBLIC pCurrUser
SELECT SviewAccess
=REQUERY("SviewAccess")
LOCATE FOR ALLTRIM(UserName) = ALLTRIM(pCurrUser)
IF FOUND()
REPLACE AccessStatus WITH "LOGOUT"
THISFORM.REFRESH
ENDIF

CLEAR EVENTS
ON ShutDown
QUIT

Journal Entries on Journal Form

Upon clicking the grid a new form will appear where you can add information. It will also retain information from previous form such as Journal Number, Reference Documents and Particular.

PUBLIC pJournalNo, pJeNum, pRefDocu, pPart
IF !EMPTY(THISFORM.Text5.VALUE)
IF !EMPTY(THISFORM.Text7.VALUE)
THISFORM.Cs_Branches()
pJournalNo = THISFORM.Text5.VALUE
pJeNum = INT(THISFORM.Text7.VALUE)
pRefDocu = THISFORM.Text8.VALUE
pPart = THISFORM.Text1.VALUE
DO FORM "C:\GenLed\Forms\JournalForm"
ELSE
pJournalNo = THISFORM.Text5.VALUE
pRefDocu = THISFORM.Text8.VALUE
pPart = THISFORM.Text1.VALUE
pJeNum = ""
DO FORM "C:\GenLed\Forms\JournalForm"
ENDIF
ELSE
=MESSAGEBOX("Select a Journal Number", "Confirmation")
ENDIF
THISFORM.Grid1.Refresh

SQL Connections

Using SQL Server, you will need a connection string to be able to access the database. Here is the basic connection string format.

DRIVER=sql server;SERVER=ServerName;UID=UserName;PWD=Password;APP=Microsoft Visual;WSID=PcName;DATABASE=DatabaseName

Do not forget to verify connection.

Add Image on FoxPro Background

Are you bored on all white background of your FoxPro Program? Now you can pick or put a background image on your program. Just include this line of code on your main program and specify the locatin of the image.

_screen.picture = "C:\GenLed\Images\background.bmp"

Trial Balance Report

Here is the sample report designer or FRX. You can use groups in the report designer. As you can see, I used Data Groupings. You will group by the field "Name" for example. In the group footer, you can use a variable which sums the field "amount". Right click your report and look at the tabs Data Grouping and Variables.

Special Thanks to Samir of Foxite.

Activity Log Code

This is the first time I will be using Activity Log on my program. Where the User or Admin can view the activity of a certain user such as adding or editing. You can also add certain specific information such as amount and account chart of journal entries.

SELECT SviewActivityLog
APPEND BLANK
REPLACE UserName WITH pCurrUser
REPLACE ActivityDate WITH DATE()
REPLACE ActivityLog WITH "Add Journal Entries in "+ALLTRIM(pBranchName)+".."

SELECT SviewActivityLog
APPEND BLANK
REPLACE UserName WITH pCurrUser
REPLACE ActivityDate WITH DATE()
REPLACE ActivityLog WITH "Edit Journal Entries in "+ALLTRIM(pBranchName)+".."

Login Code

Login Code

SELECT SviewAccess
=REQUERY("SviewAccess")
PUBLIC pCurrUser, pBranchName
LOCATE FOR ALLTRIM(LOWER(Username)) = ALLTRIM(LOWER(THISFORM.Text1.Value))
IF FOUND()
IF ALLTRIM(AccessStatus) = "LOGOUT"
IF THISFORM.Text3.Value = 3
WAIT WINDOW "Three (3) incorrect attempts." NOWAIT
REPLACE SviewAccess.AccessStatus WITH "BLOCK"
THISFORM.Release()
QUIT
ELSE
IF EMPTY(ALLTRIM(THISFORM.Text2.Value))
WAIT WINDOW "Cannot continue without password." NOWAIT
ELSE
IF EMPTY(ALLTRIM(THISFORM.Combo1.Value))
WAIT WINDOW "Cannot continue without Branch Office." NOWAIT
ELSE
IF LOWER(ALLTRIM(Password)) == LOWER(ALLTRIM(THISFORM.Text2.Value))
WAIT WINDOW "Welcome " + Username NOWAIT
pDept = ALLTRIM(sviewaccess.AccessDepartment)
pCurrUser = ALLTRIM(Username)
pFullName = ALLTRIM(FullName)
pPassword = ALLTRIM(sViewAccess.Password)
pBranchName = ALLTRIM(THISFORM.Combo1.Value)
IF (ALLTRIM(THISFORM.Text1.Value)) = "MUFFIE"
ELSE
REPLACE SviewAccess.AccessStatus WITH "LOGIN"
ENDIF
THISFORM.ActivityLogin()
SELECT SviewAccess
=TABLEUPDATE(.T.)
THISFORM.Release()
=REQUERY("SviewAccess")
ELSE
WAIT WINDOW "Incorrect Password." NOWAIT
THISFORM.Text3.Value = THISFORM.Text3.Value + 1
THISFORM.Text2.SetFocus()
ENDIF
ENDIF
ENDIF
ENDIF
ELSE
=MESSAGEBOX("User currently Logged In : "+ ALLTRIM(SviewAccess.FullName)+" station.", "MultiUser: Block")
ENDIF
ENDIF

Public

Recently I learned how to use PUBLIC in getting info or data from another form to another form. And it was very usable for me since my program has a login and branch name requirements.

On Login Form
PUBLIC pBranchName
pBranchName = ALLTRIM(THISFORM.Combo1.Value)

On Branch Setting Form
PUBLIC pBranchName
THISFORM.Label18.Caption = pBranchName

On Journal Entry Form
PUBLIC pBranchName
LOCATE FOR ALLTRIM(BranchName) = ALLTRIM(THISFORM.Combo1.Value)
pBranchName = ALLTRIM(BranchName)
= MESSAGEBOX("You select "+ALLTRIM(pBranchName)+" Office?", "Confirmation")
THISFORM.Release()

Cancel Close Code



If you want your button's picture to change when your Close/Cancel button also changed.

IF THIS.Picture = "c:\SalesMarket\Images\close.jpg"
THISFORM.Release()
ELSE
THIS.Picture = "c:\SalesMarket\Images\close.jpg"
THISFORM.ReadOnlyTrue()
THISFORM.Combo1.Enabled = .F.
THISFORM.cmdPrint.Enabled = .T.
THISFORM.cmdEdit.Enabled = .T.
THISFORM.cmdEdit.Picture = "c:\SalesMarket\Images\edit.jpg"
ENDIF

Local View and Remote View

Samples of Local View and Remote View with different filter using like, between and =.

SELECT SviewAccountChart
lAccountCode = ALLTRIM(THISFORM.Text16.Value)+"%"
=REQUERY("SviewAccountChart")

SELECT SviewJvHeader
lJvNo = ALLTRIM(THISFORM.Text20.Value)+"%"
lJvBranch = ALLTRIM(THISFORM.Text21.Value)+"%"
=REQUERY("SviewJvHeader")

SELECT SviewCheckIssueReg
lCheckNum = ALLTRIM(THISFORM.Text20.Value)+"%"
lCheckType = ALLTRIM(THISFORM.Combo3.Value)+"%"
StartDate = THISFORM.Text14.Value
EndDate = THISFORM.Text15.Value
=REQUERY("SviewCheckIssueReg")

Opening a PDF File

You can open a PDF file in VFP b using below codes. Just specify the location of your PDF file on cFileName

DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin
cFileName = "c:\GenLed\Images\CC.pdf"
cAction = "open"
ShellExecute(0,cAction,cFileName,"","",1)

Close or Exit Code

Sometimes when you tried to exit or close the program but unsuccessfully close. Try below codes. This is due to the READ EVENTS that sre still running so you need to CLEAR EVENTS then QUIT.

CLEAR EVENTS
QUIT

Disable Code

How to disable command button, text box, combo box, grid and pageframe:


Thisform.Command1.Enabled = .F.
Thisform.Text1.Enabled = .F.
Thisform.Combo1.Enabled = .F.
Thisform.Grid1Enabled = .F.
Thisform.Pageframe1.Enabled = .F.

FoxPro Graph

To those who are neophyte in VFP Language might have a hard time researching and building a graph in a form and report. I also had a hard time making a graph when I first encountered a VFP Project with a graph. But once you learned, it is easy for the next project to bulid a graph in form and report.

You need the following requirements before continuing to the graph:
Table
OleGraph
Grid

SELECT * FROM crewquestion INTO CURSOR MYCURSOR
TAB = CHR(09)
CRLF = CHR(13) + CHR(10)
SELECT MYCURSOR
NEWDATA = TAB + "Recruitment & Selection" + TAB + "Documentation" + TAB ;
+ "In House Training" + TAB + "Accounting Activity" + TAB + "Working Gears" + ;
CRLF
SCAN
NEWDATA = NEWDATA + TAB + STR(question1) + TAB + STR(question2) + TAB ;
+ STR(question3) + TAB + STR(question4) + TAB + STR(question5) + ;
CRLF
ENDSCAN
SELECT crewquestion
APPEND GENERAL crewques1.Olegraph DATA NEWDATA
SELECT crewquestion
THISFORM.REFRESH

SELECT * FROM crewquestion INTO CURSOR MYCURSOR
TAB = CHR(09)
CRLF = CHR(13) + CHR(10)
SELECT MYCURSOR
NEWDATA = TAB + "Padala Sytem" + TAB + "Company Facilities" + TAB + "Attitude of Staff" + TAB ;
+ "P&I Medical Assistance" + CRLF
SCAN
NEWDATA = NEWDATA + TAB + STR(question6a) + TAB + STR(question6b) + TAB + STR(question6c) + TAB ;
+ STR(question6d) + CRLF
ENDSCAN
SELECT crewquestion
APPEND GENERAL crewques2.Olegraph DATA NEWDATA
SELECT crewquestion
THISFORM.REFRESH

Back Color

Changing the back color of an Edit Box. Same applies to Text Box, Combo Box or Grid.

THISFORM.TEXT1.BackColor = RGB(255,255,255)
THISFORM.EDIT1.BackColor = RGB(255,255,255)
THISFORM.EDIT2.BackColor = RGB(255,255,255)
THISFORM.EDIT3.BackColor = RGB(255,255,255)
THISFORM.EDIT4.BackColor = RGB(255,255,255)
THISFORM.EDIT5.BackColor = RGB(255,255,255)
THISFORM.EDIT6.BackColor = RGB(255,255,255)
THISFORM.EDIT7.BackColor = RGB(255,255,255)
THISFORM.EDIT8.BackColor = RGB(255,255,255)

Empty Box

This code lets you use an Edit Box and will saved "Y" if the edit box is not empty otherwise save "N" if the edit box is blank. This is useful if you need to show in a View what Edit Box has an input and will not include blank.

SELECT QuestionTable
REPLACE q1comment WITH THISFORM.EDIT1.Value
IF EMPTY(THISFORM.EDIT1.Value)
REPLACE Q1Indicator WITH "N"
ELSE
REPLACE Q1Indicator WITH "Y"
ENDIF

Clearpage Code

THISFORM.Text1.VALUE = ""
THISFORM.Command1.VALUE = ""
THISFORM.Pageframe1.VALUE = ""
THISFORM.Grid1.VALUE = ""
THISFORM.Combo1.VALUE = ""

Report Code

Calling a report from a form is very easy. You can even call a multiple reports that comes from your application. Microsoft Visual FoxPro is very flexible, you do not have to install other application in making print reports. VFP 's built in reports can call view from a table either local or through local area connection such as SQL from a server.

txtName = ALLTRIM(THISFORM.txtName.VALUE)
txtBirthDate = ALLTRIM(THISFORM.txtBirthDate.VALUE)
txtBirthPlace = ALLTRIM(THISFORM.txtBirthPlace.VALUE)
REPORT FORM "C:\ProjectName\Reports\Resume" TO PRINTER PROMPT NODIALOG PREVIEW

Edit Save Code

Microsoft Visual FoxPro programming language has a lot of code to edit, insert, replace or save. Using select, append, insert or replace is some of the ways to save data. I always use the select and replace because it is easy to troubleshoot when your code has a problem.

SELECT InfoNumber
LOCATE FOR IdNum = THISFORM.txtIdNum.VALUE
IF FOUND()
SELECT InfoNumber
REPLACE LastName WITH ALLTRIM(THISFORM.txtLastName.VALUE)
REPLACE FirstName WITH ALLTRIM(THISFORM.txtFirstName.VALUE)
REPLACE MiddleName WITH ALLTRIM(THISFORM.txtMiddleName.VALUE)

Do Case Code

When you have a multiple case which you would want a different action, you can use the Do Case. Do case is very useful code when used wisely.

DO CASE
CASE THISFORM.txtSqlId.VALUE = 1
MESSAGEBOX("Argentina", "Information")
CASE THISFORM.txtSqlId.VALUE = 2
MESSAGEBOX("Bangladesh", "Information")
CASE THISFORM.txtSqlId.VALUE = 3
MESSAGEBOX("Malaysia", "Information")
CASE THISFORM.txtSqlId.VALUE = 4
MESSAGEBOX("Philippines", "Information")
CASE THISFORM.txtSqlId.VALUE = 5
MESSAGEBOX("Taiwan", "Information")
CASE THISFORM.txtSqlId.VALUE = 6
ENDCASE

Export Code

Use this code when you want to export data from table to Excel File. Plus with a message box informing you if you want to do so. There is also a message box that telling you that you have successfully exported your table to an Excel File.

lAnswer = MESSAGEBOX("Generate Report, do you wish to continue?", 4, "Generator")
IF lAnswer = 6
SELECT SeafarerList
=REQUERY("SeafarerList")
COPY TO "C:\SEAFARER.XLS" XL5
=MESSAGEBOX("File successfully generated.", "Successful")
ENDIF

Edit Save Code


Most of the time neophyte VFP Programmers know how to add, edit and save data on the table. But how can we improve the form design? This is a sample I usually used, to ask or confirm if the User want to edit dat. A confirmation message box will appear with a 'Yes' or 'No'. From that the User can choose which will be the next function.

lAnswer = MESSAGEBOX("Save and update Counter Dispatch?", 4, "Confirmation")
IF lAnswer = 6
SELECT sviewbranch
LOCATE FOR IdNum = THISFORM.Text12.Value
IF FOUND()
REPLACE beginbal WITH THISFORM.TEXT1.Value
REPLACE branchname WITH THISFORM.TEXT2.Value
REPLACE branchaddress WITH THISFORM.TEXT3.Value
REPLACE branchdesc WITH THISFORM.TEXT4.Value
REPLACE debit WITH THISFORM.TEXT5.Value
REPLACE credit WITH THISFORM.TEXT6.Value
REPLACE netchange WITH THISFORM.TEXT7.Value
REPLACE ending WITH THISFORM.TEXT8.Value
REPLACE branchdescnum WITH THISFORM.TEXT9.Value
THISFORM.REFRESH
ENDIF

Retrieve Code


If you want to have an easy way to retrieve data and have it appear in a text box or combo box just by clicking a single data from that row, there is a simple remedy for that. Just follow the following code and paste it on click.

THISFORM.Text1.VALUE = sviewbranch.beginbal
THISFORM.Text2.VALUE = sviewbranch.branchname
THISFORM.Text3.VALUE = sviewbranch.branchaddress
THISFORM.Text4.VALUE = sviewbranch.branchdesc
THISFORM.Text5.VALUE = sviewbranch.debit
THISFORM.Text6.VALUE = sviewbranch.credit
THISFORM.Text7.VALUE = sviewbranch.netchange
THISFORM.Text8.VALUE = sviewbranch.ending
THISFORM.Text9.VALUE = sviewbranch.branchdescnum

Read Only Code

Thisform.Text1.ReadOnly = .T.
Thisform.Command1.ReadOnly = .T.
Thisform.Grid1.ReadOnly = .T.
Thisform.Pageframe1.ReadOnly = .T.
Thisform.Combo1.ReadOnly = .T.

Set Focus Code

You can use this code if you want to focus on a certain text. I usually use this after enabling the textboxes.

Thisform.Text1.Setfocus()

If Else EndIf Code

You can utilize this code if you want your Command box caption to be change.

IF This.Caption = "Edit"
This.Caption = "Save"
Thisform.cmdClose.Caption= "Cancel"
ELSE
This.Caption = "Edit"
Thisform.cmdClose.Caption = "Close"
ENDIF

FoxPro Window


Above image shows the working interface window of Microsoft Visual FoxPro.

  • Data
  • Documents
  • Class Libraries
  • Code
  • Other

FoxPro Accounting Form



Sample accounting form using text box, command button, grid and page frame. This is one of my interface I used in Accounting Units. It has complex functions.

Image one has motif of blue and consist of grid, page frame, several text box and several combo box. It has a function of add, edit, save, delete and other function that was require to make the User usage comfortability. It also allows you to search for a certain name and shows or retrieve the dat data on text and combo box.

Image two has more complex function than the first one. It is use for cash and check voucher. Aside from that the viewing of data being save are also incorporate. As you can see there is a five page frame available. These page is utilize to the step by step documentation of data.

While the third image for the purpose of viewing of queued data from the Operation Department thus using the Local Area Connection.

Print Report Code

This code will help you call a report. Report Form "" Preview or To Printer Prompt Nodialog Preview

Report Form "C:\Project\Reports\PrintReport" Preview
Report Form "C:\Project\Reports\PrintReport" To Printer Prompt Nodialog Preview

Delete Code

Use this programming code if you want your table in Microsoft Visual FoxPro to be deleted. Just select the table, delete all finally pack.

Select PERSONALINFO
Delete All
Pack

Add, Save , Replace Code

Sample of save, add, append and replace code:

Select PERSONALINFO
Replace NAME With Thisform.Text1.Value
Replace AGE With Thisform.Text2.Value
Replace BIRTHDATE With Thisform.Text3.Value
Replace BIRTHPLACE With Thisform.Text7.Value
Replace ADDRESS With Thisform.Text8.Value
Replace LANDLINE With Thisform.Text9.Value
Replace CELLPHONE With Thisform.Text10.Value
Replace EMAIL With Thisform.Text11.Value
Replace WEBSITE With Thisform.Text12.Value

SELECT TableName
APPEND BLANK
REPLACE FieldOne WITH THISFORM.TEXT1.VALUE
REPLACE FieldTwo WITH THISFORM.TEXT2.VALUE
REPLACE FieldThree WITH THISFORM.COMBO1.VALUE
REPLACE FieldFour WITH THISFORM.COMBO2.VALUE
INSERT INTO TableName (FieldOne, FieldTwo, FieldThree,FieldFour);
VALUES (THISFORM.TEXT1.VALUE, ;
THISFORM.TEXT2.VALUE, ;
THISFORM.TEXT3.VALUE, ;
THISFORM.TEXT4.VALUE)

Second saving a data by Edit:

SELECT TableName
REPLACE FieldOne WITH THISFORM.TEXT1.VALUE
REPLACE FieldTwo WITH THISFORM.TEXT2.VALUE
REPLACE FieldThree WITH THISFORM.COMBO1.VALUE
REPLACE FieldFour WITH THISFORM.COMBO2.VALUE
INSERT INTO TableName (FieldOne, FieldTwo, FieldThree,FieldFour);
VALUES (THISFORM.TEXT1.VALUE, ;
THISFORM.TEXT2.VALUE, ;
THISFORM.TEXT3.VALUE, ;
THISFORM.TEXT4.VALUE)

Microsoft Visual FoxPro


Microsoft Visual FoxPro is a data-centric object-oriented and procedural programming language produced by Microsoft. It is derived from FoxPro originally known as FoxBASE which was developed by Fox Software beginning in 1984. Fox Technologies merged with Microsoft in 1992, after which the software acquired further features and the prefix "Visual". The last version of FoxPro 2.6 worked under Mac OS, DOS, Windows, and Unix: Visual FoxPro 3.0, the first "Visual" version, dropped the platform support to only Mac and Windows, and later versions were Windows-only. The current version of Visual FoxPro is COM-based and Microsoft has stated that they do not intend to create a Microsoft .NET version.

FoxPro originated as a member of the class of languages commonly referred to as "xBase" languages, which have syntax based on the dBase programming language. Other members of the xBase language family include Clipper and Recital. A history of the early years of xBase can be found in the dBase entry.
Visual FoxPro, commonly abbreviated as VFP, is tightly integrated with its own relational database engine, which extends FoxPro's xBase capabilities to support SQL query and data manipulation. Unlike most database management systems, Visual FoxPro is a full-featured, dynamic programming language that does not require the use of an additional general-purpose programming environment. It can be used to write not just traditional "fat client" applications, but also middleware and web applications.