Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Invoice Form
Message
From
22/08/2000 05:12:26
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
21/08/2000 16:06:25
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Miscellaneous
Thread ID:
00407215
Message ID:
00407647
Views:
24
>>Nearly every sentence is another topic :) Better first check Tastrade.app sample. Most of the questions find an
>> answer there.
>
>I have looked into Tastrade and I can not find the answer I want, how to use the value of variable to seek and display
>the found record on the form. I don't think every sentence is another topic, it is all to do with one form. Looks like
>you guys are not going to be any help.


I'm sorry Shafid. This community has always been helpfull and I don't want to disappoint you. Let's take it step by step (but keep in mind this is not the only way o fdoing it in VFP) :
First you need tables. They would look like tables in testdata.dbc :
customer - Holding customer related info. Cust_id primary key field.(client)
products - Holding lookup info description and price. prod_id primary key. (stock)
invdetail - Holding invoice items per order.

Simple structures for tables :
Customer :
cust_id i && Customer id - indexed as primary
cust_name c(30) && Indexed
address m
phone m
...

products :
prod_id i && Product id - indexed as primary
descr c(50)
price y

invdetail :
cust_id i && Indexed
prod_id i && Indexed
qty i

-Create a form and put tables in form DE. Set order to cust_id for invdetail, prod_id for products. Set a relation between invdetail and products, invdetail is parent, relationalexpression is prod_id.
-From customer select fields except cust_id and cust_name and drop on form to create multipl controls. Set those to readonly or disable.
-Put a combobox control on form. Using builder select fields cust_name, cust_id from customer, return value from cust_id, set columnwidths to nnn,0 where nnn is builder build value for first column. Name combo cmbCustomer. Adjust width.
-Put a grid on form, set recordsource to invdetail, linkmaster 'customer', childorder 'cust_id', relationalexpression 'cust_id'. Name grid control grdInvoice.
-Put a command button with caption 'Add inv. item' with click code :
insert into invdetail ;
 (cust_id) values ;
 (val(thisform.cmbCustomer.List(thisform.cmbCustomer.Listindex,2)))
thisform.grdInvoice.Refresh()
thisform.grdInvoice.Setfocus()
-Put a combo control on form (temporary - will delete later). Name it cmbProduct and using builder select decription and prod_id from products table, return value prod_id, columnwidths nnn,0 as before. Adjust width. Select combo and Ctrl+C to copy.
-Set columncount of grid to 4. Right click on grid and select edit. Edit header captions of 4 columns to read :
Description, Price, Qty, Total.
-Set controlsources of columns 1 - 4 as :
invdetail.prod_id, products.price, invdetail.qty, (invdetail.qty*products.price)
-Set column 2 enabled to .f.
-Click column1 and Ctrl+V to paste cmbProduct that we created and copied earlier.
-Go to PEM sheet and set currentcontrol to cmbProduct and set sparse to .f. Adjust width of column + increase rowheight to accomodate (you can read the height of combo and put that value to grid.Rowheight)
-Delete combo that is temporarily created.
-Put a textbox on form and name it txtInvTotal. Set value to 0.
-Dblclick on cmbCustomer to popup code window. Select 'interactivechange' method. There code :
select sum(a.qty*b.price) ;
 from invdetail a ;
  inner join products b on a.prod_id = b.prod_id ;
  where a.cust_id = val(this.list(this.listindex,2)) ;
  into array arrInvTotal
thisform.txtInvTotal.Value = iif(_tally=0,0,arrInvTotal[1])
-From pem sheet select grid.column4.text1.
-In gotfocus put code :
this.Tag = str(this.value) && Store value on entry
-In lostfocus method code :
thisform.txtInvTotal.Value = ;
 thisform.txtInvTotal.Value + (this.Value - val(this.Tag))
You're nearly done. Arrange your form cosmetically and run. Further enhancements are up to you. Hope helped.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform