New table line item.....

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
 
M

Michel Walsh

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
 
H

Hanksor

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top