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!

Generating Records

Status
Not open for further replies.

doorok

Technical User
Mar 20, 2003
10
0
0
US
What is the best way to have access autogenerate records? I have a table and form that has an asset field and a period field. When I enter an asset name I will also enter the number of periods to depreciate. How can I make access update another table that has asset and period. For instance if I enter computer into the asset field and 12 into the period field, I want the second table to automatically generate 12 records with asset being computer and period being 1 thru 12.

Thanks,
Josh
 
use DAO

in the AfterUpdate Event where you enter the Period value add

If val(nz(TextBoxNameWithPeriod,0))>0 Then
Dim db as DAO.Database, rst as DAO.Recordset
Dim x as integer
Set db = CurrentDb
Set rst = db.OpenRecordset("YourTableNameYouWantToAppendTo")
For x = 1 to val(nz(TextBoxNameWithPeriod,0))
with rst
.AddNew
rst!Asset = TextBoxNameWithAssetData
rst!Period = x
.Update
End With
Next x
Set db = Nothing
Set rst = Nothing
End If


PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top