By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,574 Members | 2,966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,574 IT Pros & Developers. It's quick & easy.

how to add a set of records to a table

P: 76

I have a table tblYears with fields - TrnYear, Balance
And also a table called tblMonths with fields - TrnYear, TrnMonth, MthValue, DateEnd.

There is a one to many relationship between the two.

I would like from a form that when I type a Year number and click on the command button that a new record should be added with the entered value to tblYears, but also then add 1,2, through to 12 to the TrnMonth field in tblMonths. All in one click if possible.

So in short. A new should be added to tblYears, and 12 new records (1 2 3 4 5 6 7 8 9 10 11 12) to tblMonths for the same year.

Could anybody help?
Feb 25 '12 #1
Share this Question
Share on Google+
1 Reply

P: 1
Between the begin transaction and end transaction you should be insert records in both tables.

first you should be insert YEAR FIELD VALUE in tblyear table and after that just declare a variable integer type and increase variable value by 1 with in for loop and also write the insert statement of the 2nd Table TBLMONTH with in for loop with same year which you insert in first table.

i think as like u can add.
asnd if any error is generated no any record will be added in both table bacause end transaction is not executed. and after end transaction records will be saved successfully in both tables.
Feb 26 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.