Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help about OneToMany form designs !!!

Status
Not open for further replies.

kosta

Programmer
Feb 9, 2001
186
0
0
CA
Hi All,

i've trouble about OneToMany forms such as Invoice forms.
i'am using standart toolbar on my applications and i executes
add delete edit etc. commands via

_screen.activeform.addnew()
_screen.activeform.delete() ...
command for toolbar cmdbuttos click codes for form methods.

i've designed my invoice form and preffered
for parent table fields ( invoice no,invoice date,InvoiceID,subotal,tax,grandtotal ... ) with textbox,combobox etc

for child table fields ( itemCode,Quantity,price etc .. ) grid

my table(s) structures like below

invheader.dbf
---------------
myguid c(38) PK indexed && default value guid()
InvoiceId Integer regular indexed



invdetail.dbf
--------------
myguid c(38) PK indexed && default value guid()
pmyguid c(38) regular indexed && default value guid()
InvoiceId Integer regular indexed

Relation between invoiceheader.myguid -> invoicedetail.Pmyguid

grid.recordsource = invoicedetail
grid.linkmaster = invoiceheader
grid.relationalexpr = Pmyguid
grid.childorder = Pmyguid




* function for myguid field default value
Function guid()
Local pGUID,rGUID
Declare Integer UuidCreate In 'RPCRT4.dll' String @pguid
Declare Integer StringFromGUID2 In 'Ole32.dll' ;
string rguid, String @lpsz, Integer cchMax

pGUID=Replicate(Chr(0),16)
rGUID=Replicate(Chr(0),80)

Return Iif(Inlist(UuidCreate(@pGUID),0,1824),;
Iif(StringFromGUID2(pGUID,@rGUID,40) # 0, ;
Strconv(Left(rGUID,76),6), ""),"")
Endfunc
i am using LcFile1,LcFile2.. properties for assign the table names for navigate and the other actions.
such as for last method

select (thisform.LcFile1)
go bottom
_screen.activeform.refresh
my great troubles

1- when i use below codes at grid when,valid event for navigate and for other actions
when activecontrol is grid some calculations from grid afterrowcolchange event
doesnt updates in parenttable (lcfile1)



*grid when
thisform.lcfile1 = this.recordsource
_screen.activeform.refresh

* grid valid
thisform.lcfile1 = this.linkmaster
_screen.activeform.refresh

2- when i dont use above codes at grid this time it works
but record pointer moves to another usually goes lastrecord
( in form init i am redirect to last record via go bottom command )

3-when i use modal forms for add-edit occurs same things

shortly i wantto use invoice forms like i above described and parent fields
should be on textbox,combobox etc. and child fields sohould be on grid.

detail entries will be on grid and some calculations total,value addedtax,grand total will be on textbox
and calculations will auto calculate on grid afterrowcolchange event will refresh the results on textbox
and also will update the tables both of parent-child.


please helpme that where i'am doing mistaken ?
and as my wish if you were me how would be the your forms designs,settings,codes ?
or please refer me via simple code samples or show me download links about this issue

TIA

Soykan OEZCELIK
 
You seem to have a pretty good design.

What first strikes me is that you need some protective code (which you may have, and simply omitted for clarity) so that when someone clicks the Toolbar, make sure that _SCREEN.ActiveForm really has an "AddNew" method, etc.

Also, in your When/Valid methods, you use:
_screen.activeform.refresh
... Your grid is in the same form as the AddNew method, right?
so, why not simply use:
THISFORM.Refresh


I can't see this necessarily solving your problem, but sometimes things have unintended consequences (like, maybe the toolbar is ever-so-briefly made the ActiveForm when you click the toolbar button, and, consequently, while this code executes... though I'm not sure of that).

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Thanks for the reply wgcs,
i've decided to change my invoice form design with pageframed solution... by this way i don't need to any modal form for add or edit action also all off controls will show on textboxes while user navigate between records on the grid and if user want change at any records just will edit any textbox content and will save , also add action like so ...

TIA

Soykan OEZCELIK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top