This topic is locked

Insert new record in another table

5/26/2009 5:43:46 PM
ASPRunnerPro General questions
J
jeremyb author

I am using the After Record Added Event and trying to add a record within a table called Task the following information:
dal.tblTask.Task_Type="Contract"

dal.tblTask.Start_Date=Now()

dal.tblTask.End_Date=Now()+50

dal.tblTask.File_Id=Show_key1

dal.tblTask.Add()
This is to be generic informaton and only the File_id field will link the main table to the Task table. When a user creates a new record in the main table I plan to sporn a number of new records in the Task table associated with the Main Table record. There is no field in the Main table (apart from the File_Id) that is also in the Task table. This is fundamentally a project - task tracking solution. A project sporns a number of tasks.
I am currently testing with just one record called Contract in the Task table. When I add a record it works but I can't seem to be able to associuate it with the original Main record. The File_Id is tyhe field that should hold the Main table record association. How do I code this link?
Regards
Jeremyb

J
Jane 5/27/2009

Jeremy,
I suppose you want to save key value in the File_ID field.

In this case use this code:

dal.tblTask.File_Id=keys("FieldName")



where FieldName is your actual field name where primary key is stored.