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

Add Several Records to Table When New Project Added 3

Status
Not open for further replies.

mkallover

Programmer
Feb 6, 2008
88
US
What I would like to do is add several records to a milestones table (tblMilestones) whenever a user creates a new project. There are milestones like beginning design, going to coding, entering QC that are consistent for every project. What I would like to do is create those records on the fly whenever a user creates a new IT project in the database.

What would be the best way to do that? Would I just have to create several INSERT queries in my VB code or is there a better way?
 
You could maintain small milestones table and append that.
 
Yes, that's what I have in the tblMilestones. Milestones are then linked to the project by the ProjectID. Every project has the same set of milestones so I'd like a way for the business owners to get those in quickly.

So I take it that using several INSERT queries triggered by VBA is probably the best way to do that?
 
You could create Insert queries. Another way is one I used to update tables in a school database. When a student enrolled, his info had to go into 7 different tables, so (I only show two tables for example)

Dim db As Dao.Database
Dim rs As Dao.Recordset
Dim rst As DAO.Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("Attendance", dbOpenDynaset)
rs.AddNew
rs![ID] = Me![ID]
rs![FirstName] = Me![FirstName]
rs![LastName] = Me![LastName]
rs.Update
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing

Set db = CurrentDb()
Set rs = db.OpenRecordset("Bus Information", dbOpenDynaset)
rs.AddNew
rs![ID] = Me![ID]
rs![FirstName] = Me![FirstName]
rs![LastName] = Me![LastName]
rs.Update
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing

Place it on the OnClick event of a Save button.
 
Godfrey Daniels! Someone caught that. A teacher created the tables and I pointed that out to her. Normalization violation and all that. She just stared blankly at me.
Didn't think my own medicine tasted so bad...
Good eyes, PHV. Don't you have holiday shopping to do?
 
I failed to explain myself.

tblAppendMilestones
Milestone1
Milestone2
Milestone3

INSERT INTO tblMilestones (ProjectID, Milestone)
SELECT Forms!frmForm!ProjectID, Milestone FROM tblAppenMilestones
 
Thanks all, great stuff. I'll tinker around with these techniques.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top