N
NKK
I have a form bound to a table (dt_accounts) with an unbound listbox that I
have set up to insert multiple records into another table (dt_accountrole)
that has a many to 1 relationship to the table the form is based on. The
field Account_id is the primary key in dt_accounts and a foreign key in
dt_accountrole. For every selection in the list box, a record is entered
into the dt_accountrole table using the following vba code (thanks to someone
else in this group!):
Dim varItem As Variant
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("dt_AccountRole", dbOpenDynaset)
With Me.lboAcctRole
For Each varItem In .ItemsSelected
rst.AddNew
rst![Role_id] = .ItemData(varItem)
rst![Account_id] = Me.Account_id
rst.Update
Next varItem
End With
rst.Close
Set rst = Nothing
End Sub
This code is on the exit event...my problem is that if I move to the next
record, the selections from the previous record are still highlighted. How
to I "clear" the selections from the list box when moving between records?
Thanks in advance
have set up to insert multiple records into another table (dt_accountrole)
that has a many to 1 relationship to the table the form is based on. The
field Account_id is the primary key in dt_accounts and a foreign key in
dt_accountrole. For every selection in the list box, a record is entered
into the dt_accountrole table using the following vba code (thanks to someone
else in this group!):
Dim varItem As Variant
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("dt_AccountRole", dbOpenDynaset)
With Me.lboAcctRole
For Each varItem In .ItemsSelected
rst.AddNew
rst![Role_id] = .ItemData(varItem)
rst![Account_id] = Me.Account_id
rst.Update
Next varItem
End With
rst.Close
Set rst = Nothing
End Sub
This code is on the exit event...my problem is that if I move to the next
record, the selections from the previous record are still highlighted. How
to I "clear" the selections from the list box when moving between records?
Thanks in advance