Add multiple values on table based on listbox

Joined
Oct 29, 2013
Messages
1
Reaction score
0
Hi everone,

Hope you are Ok. I have a database with a table that contains taks called "tblMain". Each entry is a task that is performed in my team. There are tasks that are done specifically for a type of visa, however there are tasks that are done the same regardless the visa, so I have to create the same task as many type of visas are. Since creating the several entries for same task for each visa is too much work, I want to create a form in which I can complete the rest of the fields for the task and in the visa type I had created a List Box. I wanted a code to create several entries for the same tasks and on the visa type to add the visa type. I had found codes in the web and I had managed to create one, however it creates one row and on visa type, all the visas types that I had selected and this is not what I want. I want as many rows/entries to be created as many visas types including on the field only one of the visa types selected and so on. The reason why I want this is because I have queries with Sums depending on the visa type. Do you know if what I am trying to achieve is possible?

Please find my code below
Code:
Private Sub cmdUpdate_Click()
 Dim valSelect As Variant, MyDB As DAO.Database, MyRS As DAO.Recordset
 
Set MyDB = CurrentDb()
Set MyRS = MyDB.OpenRecordset("tblMain", dbOpenDynaset)
 
MyRS.MoveFirst
 
For Each valSelect In Me.Lista113.ItemsSelected
  MyRS.AddNew
    MyRS![Visa Type] = Me.Lista113.ItemData(valSelect)
    MyRS![GU] = GU
    MyRS![Country] = Country
    MyRS![Task] = Task
    MyRS![Team] = Team
    MyRS![Division] = Division
    MyRS![TransactionalTime] = TransactionalTime
    MyRS![ConstantTime] = ConstantTime
  MyRS.Update
Next valSelect
 
MyRS.Close
Set MyRS = Nothing
End Sub
 

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

Top