VXFORM3 Aircraft Brokerage Customers Form1- Label1 Tms Rmn Label2 Last Name, First Name Tms Rmn Label3 Company Tms Rmn CustCode Tms Rmn CustName Tms Rmn CustCompany Tms Rmn Label4 Address Tms Rmn Label5 Tms Rmn Label6 State Tms Rmn CustAddress Tms Rmn CustCity Tms Rmn A CustState Tms Rmn CustStateHelp Tms Rmn Label7 Tms Rmn Label8 Res Phone Tms Rmn Label9 Bus Phone Tms Rmn Label10 Tms Rmn CustZip Tms Rmn C CustPhRes Tms Rmn D CustPhBus Tms Rmn CustFax Tms Rmn Label11 Created Tms Rmn Label12 Days on File Tms Rmn BuyRecs Bu&y Recs Tms Rmn Picture1 9 CustBuyer Buyer Tms Rmn CustSeller Seller Tms Rmn F CustCdate Tms Rmn CustDays Tms Rmn Aircraft Ai&rcraft Tms Rmn Label13 Revised Tms Rmn G CustRdate Tms Rmn CustSave &Save CustCancel &Cancel CustAdd CustDelete &Delete CustMemo &Memo CustNext &Next CustPrevious &Previous CustBrowse &Browse CustExit E&xit Label14 Status Tms Rmn CustStatus Form_LoadX vxSelectDbf AircustDbf Form3ActiveG CustReturn1 BROWSE_ADD6 CustDataClear CustStatus text( CustSave Enabled CustCancel CustMemoJ FALSEh CustAddM CustDeleteY BuyRecsU aircraft CustCode BROWSE_EDIT CustDataLoad vxTrue vxRecNo CustName CustCompany CustAddress CustCity$ CustState CustZip CustPhRes> CustPhBus CustFax CustBuyer Value6 CustSeller1 CustCdateO CustRdate CustDaysX CursorWaitj EnableCustDatac vxField DateCreate vxDateFormat xDate DaysOnFiler vxDateString VX_AMERICAN CustKey vxUnLock CursorArrow DisableCustData& CustCode_GotFocus vxCtlLengthL CustCode_KeyPress KeyAsciip CustName_KeyPressy CustCompany_KeyPress CustAddress_KeyPress CustCity_KeyPress CustZip_KeyPress CustPhRes_KeyPress CustPhBus_KeyPress CustFax_KeyPress CustState_KeyPress% CustName_GotFocus= CustAddress_GotFocusR CustCity_GotFocush CustState_GotFocus| CustZip_GotFocus CustPhRes_GotFocus CustPhBus_GotFocus CustFax_GotFocus> CustSave_Click SeekKey EmptyStringa vxSeek AirstateDbf~ vxSelectNtx Airstat1Ntx* IsBuyer IsSellerB WasBuyer WasSellerU RDatec CDate vxAppendBlank0 vxReplString vxReplDate vxWriteE RecNumber vxClose( BuyerOpen! Airbuy1Ntx vxEof vxDeleteRec vxSkip RecNum AirbuyerDbf AircraftOpenr Aircraf1Ntx StatesOpen CustStateHelp_Click SaveReturn9 BROWSE_USER Airstat2Ntx StateReturn VXFORM3 vxBrowse CustAdd_Click CustCancel_Click CustBrowse_Click7 Visible BrowseCust CustDelete_Click' CustExit_Click| CustNext_Click$ CustNexth CustPrevious CustBrowse vxDeleted vxBottom CustPrevious_Click? vxBof vxTop Form_UnloadT Cancel vxWindowDereg VXFORM1[ OpenTypes OpenCust OpenAircraft LinkBuyToSell LinkSellToBuy PackFiles TestCreateK TestCopyc TestDataCopy FileStruc~ CustBuyer_KeyPress7 CustSeller_KeyPress BuyRecs_Click TypesOpen BofExpr EofExpr vxTableDeclare VX_RED vxTableField VX_FIELD VX_EXPR BuyerRecB BrowseBuyers BuyerReturn VXFORM4 Aircraft_Clicko AircraftDbf vxUseDbf AirtypesDbf vxUseNtx Aircraf2Ntx AircraftReturn VXFORM5 CustMemo_Click vxMemoEdit Form_Paint vxFormFrame vxCtlStyle VX_RAISE VX_RECESS Picture1 BROWSE_DELETE CustCompany_GotFocus Form_Load On form load analyze results of browse return Record addition request" if user pressed ENTER then file is positioned at current record and the record number isn returned in CustReturn. In this case we assume he wants to edit that record. call general proc to load controls- can't change key- a_seller a_buyer" Edit record CustDataClear Clear Form in preparation for add or after successful delete dd-mmm-yyyy" dd-mmm-yyyy" CustDataLoad Load data from customer record ensure data entry enabled extract field values- a_code a_name a_company" a_address" a_city a_state" a_zip" a_phoneres a_phonebus a_fax" Return from logical field interrogation vxTrue() is -1 (TRUE) or 0 (FALSE). By using the unary negation operator we will transform any -1 values to the checkbox value 1, which means "selected" a_buyer" a_seller vxDateFormat() routine returns a date in the- format dd-mmm- y, which the Visual Basic DateValue function inderstands. We will put the creation date into a variable so we can perform some date arithmetic on it to determine the number of days on filei a_cdate" dd-mmm-yyyy" use the vxDateString function as an example of display dates a_rdate" set customer key for other links- EnableCustData enables all data entry controls on the form which are disabled by the CustCancel_Click Proc DisableCustData Disables data entry when the cancel button- is presseda CustCode_GotFocus set up text length limit- a_code# CustCode_KeyPress Convert customer code to uppercase as it is being entered also convert enter key to tab {Tab}" CustName_KeyPress {Tab}" CustCompany_KeyPress {Tab}" CustAddress_KeyPress {Tab}" CustCity_KeyPress {Tab}" CustZip_KeyPress {Tab}" CustPhRes_KeyPress {Tab}" CustPhBus_KeyPress {Tab}" CustFax_KeyPress {Tab}" CustState_KeyPress {Tab}" CustName_GotFocus a_name# CustAddress_GotFocus a_address"# CustCity_GotFocus a_city# CustState_GotFocus a_state"# CustZip_GotFocus a_zip"# CustPhRes_GotFocus a_phoneres# CustPhBus_GotFocus a_phonebus# CustFax_GotFocus a_fax"# CustSave_Click Validate data when save button is pressed verify something in the field Field cannot be empty" verify unique key if adding Duplicate Key on Add verify that state code is in states file- on code State code not found set vxbase logical values based on- status of check box if we're updating a record, save old buyer/seller status in case we have to make adjustments to the buyer and aircraft files if the status changes a_buyer" a_seller set up date strings in preparation for replace- dd-mmm-yyyy" dd-mmm-yyyy" a_cdate" Data passed. Put it away a_code a_name a_company" a_address" a_city a_state" a_zip" a_phoneres a_phonebus a_fax" a_buyer" a_seller a_cdate" a_rdate" we might have a new revision date a_rdate" Update status box Record " appended" Record " saved enable/display buyer/aircraft buttons set global CustKey for links to buyer and aircraft files save record number- Close states file to free some handles- also does vxTableReset- Test old buyer status and remove records from buyer file if he is no longer a buyer but once wasm in VXBMOD.BAS in cust code order- Confirm delete of existing buyer records b_code if delete denied then reset buyer status to true a_buyer" Test old seller status and remove record from aircraft file if he is no longer a seller but once was in VXBMOD.BAS in cust code order- Confirm delete of existing aircraft record if delete denied then reset seller status to true a_seller reopen states file in VXBMOD.BAS Update Button Status CustStateHelp_Click display a browse window on the state file. If the user double clicks a state or presses ENTER on a highlighted record, we'll get the record number back and we can stuff the state code into CustState.text on state name State and Provincial Abbreviations after a browse, always re-register the database with the window with a vxSelectDbf before attemptingA to access a field in the help file. statecode" CustAdd_Click clear form for addition of new record Record Addition Request" ensure data entry enabled reset the buttons CustCancel_Click Clear form data and reset button status Operation cancelled" we must disable data entry because the user could enter a new record in the blank boxes and then press the Add button. The TypeAdd_Click- routine clears the form boxes again prior tol accepting input so the user's work would be lost- and he would be mad.h CustBrowse_Click so we don't close files when we unload the form CustDelete_Click get user confirmation of delete Confirm Delete we must also delete any attached buyer and- aircraft recordse set global CustKey for links to buyer and aircraft filese save record number- Close states file to free some handles- also does vxTableReset- delete buyer recordsv in VXBMOD.BAS in cust code order- b_code delete aircraft record in VXBMOD.BAS in cust code order- reopen states fileu in VXBMOD.BAS now delete the requested record Deleted Delete failed" Delete cancelled CustExit_Click current form is unloaded because if needed again the form_load proc must be invoked to reset the control datad CustNext_Click skip forward one record if skip error, only allow exit- Error on Skip Next. Try Reindex. test for end of file End of File! Skipped to record rec unlocked here CustPrevious_Click skip back one recorde if skip error, only allow exit Error on Skip Previous. Try Reindex. test for beginning of filer Beginning of File! Skipped to record Form_Unload close customer and state files and reset table and restart menu window if we'ree NOT being unloaded by BrowseCust CustBuyer_KeyPress {Tab}" CustSeller_KeyPress {Tab}" BuyRecs_Click open airtypes file and buyer file Set up browse table limited to buyer records that match the CustKey. We do this by sending the vxTableDeclare proc a beginning ofs file expression and an end of file expression. b_code < ' b_code > ' The vxBrowse object now knows to limit the- records in the table to those that have b_code values equal to CustKey. We also scope the records with the "6" following the EofExpr and set the quick key index tot "7". An explanation follows:d The key we are going to use to browse this file isd b_code + b_cat, whose elements are 6 long and 3 long respectively. Every record we are interested in has thet same b_code (i.e., they all belong to the same customer). Setting the scope index to 6 determines the action to be. taken when the HOME or END keys are depressed. The normal value is 0, which takes you to the first and last logical records in the file when HOME or END is hit. If other than zero, then the HOME key will result in a softseek on thea file to the current key for the length specified by the scope index. The END key will softseek to the current key plus 1 and then skip back one record to position thet record pointer to the last record in the group. The quick index is set to 7, which is the first positiony of the aircraft type code in the key. We aren't event going to display the b_code for the buyer records. Setting the quick index to 7 means that the common part of the key for the group of records we are interested in (the firste 6 which form the customer code), will be prepended to the quick keys entered at the keyboard before a seek is donee on the file. Makes sense, huh?o When scoping a file in this fashion, the only thing you MUST do is position the record pointer to the first record in the group and then pass that record number to the vxBrowse proc (the StartRec& parameter). b_cat" Description" b_desc b_low" b_high STR((b_high / b_low)*100,7,2)" Because we are interested in only a subset of the possible records in the buyer file, we have to determine ourselves whether there are any records in the file that match thes group. If not, we ask the user if he wants to add a record. vxBrowse normally does this, but the file must be empty before it asks the question and sets the return value accordingly.k global var- set for browse start rec- No buyer records. Add? Aircraft_Click there is only one aircraft sell record allowed- to a customer so this makes it a little simpler Close states file to free some handles- also does vxTableReset- open airtypes file and aircraft file- \vb\vxbtest\aircraft.dbf Error Opening aircraft.dbf. Aborting." \vb\vxbtest\aircraf1.ntx \vb\vxbtest\aircraf2.ntx No aircraft records. Add?" CustMemo_Click Edit memo. Always have an ENABLED form showing to act as- parent to the memo window. It also must have the focus. Copy the code below EXACTLY to ensure successful memoedits. save rec num to goto later- make sure form has focus a_memo# reset rec buffera unlock the record Form_Paint if delete request from browse, do it now because we must let enhanced controls paint before asking for delete confirmation CustCompany_GotFocus a_company"#