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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking new files to a common db2k form

Status
Not open for further replies.

dougpke

Programmer
Sep 13, 1999
2
US
I am developing an application that needs to have new tables attached to the same form each month. The table formats are exactly the the same, only the table names and data change. What do I need to do to link a new table to the form each month, without editing all the datalinks on the form each time? Thanks in advance.
 
The best way to handle this is to use Macro substition for the table name. For Example;

nTable1 = Form.Entryfield1.Value //(An Entryfield on a field for the user to enter the new table name)
nTable2 = Form.Entryfield2.value

Select 1
Use &nTable1 Tag SomeField

Select 2
Use &nTable2 Tag someField

Set Relation to Somefield into &nTable1
Also you can use a predictive naming convension for the table name by replacing the Entryfields with a Program segment like

nTable1 = "EMP" + Substr(DTOC(DATE()), 1, 2) +;
SUBSTR(DTOC(DATE()), 7, 2) + ".DBF"

This would result in a table named, "EMP0602.DBF"
Each month the table name would change, July would = "EMP0702"

you would probabley want to test that the file exists before executing these command with code like;
IF File("C:\Tables\EMP" + Substr(DTOC(DATE()), 1, 2) +;
SUBSTR(DTOC(DATE()), 7, 2) + ".DBF")

Good luck feel free to let me know if you have questions.
RRiley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top