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

Append records to table using variable on form

Status
Not open for further replies.

Herdrich

Technical User
Dec 30, 2008
83
US
I have a database that keeps track of employee training completion and due dates and im trying to figure out how to append a new training record to everyone’s record in the database. what I have now is if a new user is created a template is put into their record with all of the required training. The problem that im having is that the type of training everyone needs sometimes changes and i want to be able to add it to people that are already in the system

I have everyone’s information listed in the PersonnelMain table I want to pull the SSN from there then use the data from Me.Combo14 for the training type then use Date for DateCompleted and DateDue. I just cant figure out a route on how to do this any guidance would be awesome

PersonnelMain.SSN = *, Type = Me.Combo14, DateCompleted = Date, DateDue = Date

 
put a command button on the form and run this code on the click

currentdb.execute "insert into Traingtable (SSn,Type,DateCompleted,DateDue)"
Select PersonnelMain.SSN, " & Me.Combo14 & ",Date(),Date()
From PersonnelMain
 
Having a bit of trouble getting this to run i found this witch talks about what you gave me but i cant get it to run tried it the way you had it this way and without the currentdb.execute still no luck.

Code:
CurrentDb.Execute INSERT INTO "Training" ("SSN", "Task", "DateCompleted", "DateDue")
SELECT "PersonnelMain.SSN", '" & Me.Combo14 & "', Date(), Date()
From Training

I get an expected end of statement on "Training" for the first line and expected case for "PersonnelMain.SSN
 
Last line of code is actually
Code:
From PersonnelMain
 
Well guess i asked too soon figured it out

Code:
CurrentDb.Execute "INSERT INTO Training (SSN, Task, DateCompleted, DateDue) SELECT SSN, '" & Me.Combo14 & "', Date(), Date() From PersonnelMain"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top