Hi everyone,
Hope you are right. I have an issue with a code that I have in a form which adds rows in a table as many times as categories chosen from a list. However, the code is not working correctly: it adds the information and creates a row with a category in blank, in addition to the rest of the rows with one of the chosen categories. I would like for this not to happen, to add only as many rows as the categories chosen.
My code is the following:
Can you help me please? Thanks!!!
Hope you are right. I have an issue with a code that I have in a form which adds rows in a table as many times as categories chosen from a list. However, the code is not working correctly: it adds the information and creates a row with a category in blank, in addition to the rest of the rows with one of the chosen categories. I would like for this not to happen, to add only as many rows as the categories chosen.
My code is the following:
Code:
Private Sub cmdUpdate_Click()
Dim valSelect As Variant, MyDB As DAO.Database, MyRS As DAO.Recordset
Set MyDB = CurrentDb()
Set MyRS = MyDB.OpenRecordset("Tasks", dbOpenDynaset)
MyRS.MoveFirst
For Each valSelect In Me.listVisaType.ItemsSelected
MyRS.AddNew
MyRS![VisaID] = Me.listVisaType.ItemData(valSelect)
MyRS![GuID] = GuID
MyRS![CountryID] = CountryID
MyRS![Transactional Time] = TimetoPerformtheTask
MyRS![TeamID] = TeamID
MyRS![TaskName] = TaskName
MyRS.Update
Next valSelect
MyRS.Close
Set MyRS = Nothing
End Sub
Can you help me please? Thanks!!!