Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using the same form for different tables
Message
From
08/07/1999 00:02:52
 
 
To
07/07/1999 14:06:33
Steven Herbin
SNH Computing Corporation
Swan Lake, New York, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00238420
Message ID:
00238673
Views:
15
>I have a payroll system written in FoxBase (about 10 years ago). I migrated it to FP DOS when I inherited it 5 years ago. We are now rebuilding it in VFP (v6 sp3). There are 4 companies, each with its own personnel file, payroll files, etc. However, the rules are basically the same for all companies.
>
>I would like to use the same forms to edit each company's records. That is have one personnel form, one payroll corrections screen, etc.
>
>In FPDOS or FPWin, we would simply pass a parameter to the screen, and in the setup code select the appropriate table, give it an alias, and process away.
>
>In VFP, from what I have seen, the form's controls are instantiated before the INIT for the form, so a parameter can't be used to select the appropriate table...the table needs to be open at the time the controls are instantiated since they are bound.
>
>I guess I'm just searching for a clue or an idea. This seems to be a problem that is much more complicated in VFP than it was in FPWin.
>
>Thanks in advance.




First of all, you'd better to change the setting in Run-Time instead of making handling on Form.init()

In File Section, Forms, I have a tool bwtable.zip which change the grid data on RUN-TIME after user change the Table Combox value..

For more detail on handling Changing Grid Recordsource on Run-Time, you need to download it and see the coding! ^_~

You Also can do this!!




What you need to do:
Add a Combox which has 4 values on each Company Name!
* CobCompany.InterActiveChange()

THISFORM.MOUSEPOINTER=11
THISFORM.LOCKSCREEN=.T.

USE IN myStaff   && the common alias name...
USE IN myStaffHis  

DO CASE
CASE THIS.VALUE = "Company A"
   USE c:\comp_A\Staff Again in 0 ALIAS myStaff Order Tag Staff_id
   USE c:\comp_A\Staffhis Again in 0 ALIAS myStaffHis ORder Tag Staff_id

CASE THIS.VALUE = "Company B"
   USE c:\comp_B\Staff Again in 0 ALIAS myStaff Order Tag Staff_id
   USE c:\comp_B\Staffhis Again in 0 ALIAS myStaffHis ORder Tag Staff_id

CASE THIS.VALUE = "Company C"
   USE c:\comp_C\Staff Again in 0 ALIAS myStaff Order Tag Staff_id
   USE c:\comp_C\Staffhis Again in 0 ALIAS myStaffHis ORder Tag Staff_id

CASE THIS.VALUE = "Company D"
   USE c:\comp_D\Staff Again in 0 ALIAS myStaff Order Tag Staff_id
   USE c:\comp_D\Staffhis Again in 0 ALIAS myStaffHis ORder Tag Staff_id

ENDCASE

With Thisform.GridStaffHis
   .ColumnCount = -1  && Reset and release all column objects!!
   .Recordsource = ""
   .Recordsource = "MyStaffHis"  && Re-Assign Again 
   .Init()  && adding some coding to change the textbox coontrol correspondingly
EndWith

THISFORM.MOUSEPOINTER=0
THISFORM.LOCKSCREEN=.F.
THISFORM.REFRESH()
Since all the textbox, combox, and simple control will NOT get problem because the controlsource ALIAS has been Defined!!

For handling Grid control, you need to do more coding!!

Don't do ANY Refresh() nor SetFocus() coding if you Use In xxx alias..
Else Error comes as alias NOT Found!!

Another Method to handling is to:

change all controlsource, recordsource, rowsource to corresponding ALIASNAME and you open those file in different alias name...

e.g.
Use c:\Comp_B\Staff AGain in 0 Alias B_Staff
Thisform.txtStaff_Id.controlsource = "B_Staff.Staff_id"
Thisform.txtStaff_name......
....

~_~ of cos, it will very long coding and NOT good enough!!!

The first one is the best method, if afraid user quick setfocus on some textbox control, you can EVEN hide the form and re-show it after coding finish!!

~_^ Good Luck!!
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Reply
Map
View

Click here to load this message in the networking platform