New table line item.....

  • Thread starter Thread starter Hanksor
  • Start date Start date
H

Hanksor

Is it possible to add a new line item in a table for each form object on a
form? For example;
EmpID, text1, text2, text3, etc......
For Example:
EmpID, text1
EmpID, text2
EmpID, text3

I hope this makes sense.... Any help will be appreciated.

Hanksor
 
Hi,


I would use a loop like (assuming text1 to text25, and the fields name
are id and f1) :


For i = 1 To 25

DoCmd.RunSQL "INSERT INTO myTable( id, f1) VALUES( FORMS!FormName!EmpID,
FORMS!FormName!Text" & i & ")"

Next i



You can also try:


For i = 1 to 25
CurrentDb.Execute "INSERT INTO myTable(id, f1) VALUES(" & Me.EmpID & ",
""" & Me.Controls("Text" & i).Value & """ )", dbFailOnError

Next i





Hoping it may help,
Vanderghast, Access MVP
 
Thanks!!! worked great............
Michel Walsh said:
Hi,


I would use a loop like (assuming text1 to text25, and the fields name
are id and f1) :


For i = 1 To 25

DoCmd.RunSQL "INSERT INTO myTable( id, f1) VALUES( FORMS!FormName!EmpID,
FORMS!FormName!Text" & i & ")"

Next i



You can also try:


For i = 1 to 25
CurrentDb.Execute "INSERT INTO myTable(id, f1) VALUES(" & Me.EmpID & ",
""" & Me.Controls("Text" & i).Value & """ )", dbFailOnError

Next i





Hoping it may help,
Vanderghast, Access MVP
 
Back
Top