Inserting List Box Values into Table

forms_are_nightmares

Registered User.
Local time
Today, 14:21
Joined
Apr 5, 2010
Messages
71
Hello All,

Looking for some help.

Scenario: User selects multiple values from a list box, selects a value from an unbound combo box and clicks submit. I would like to write the values selected from the list box into the table. The below code works for everything but the values selected in the list box.

Can anyone help me in getting those values to populate into the table?

thanks...

Private Sub AddDoc_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim var As Variant
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl_document")

row = DocList.ListIndex

If DocList.ItemsSelected.Count = 0 Then
MsgBox "No Documents Selected...", vbExclamation
End If

For Each row In Me.DocList.ItemsSelected
With rs
.AddNew
.Fields("ID") = Me.ID
.Fields("DStatus") = "Incomplete"
.Fields("DDate") = Date
.Fields("Document") = DocList.Column(4, row)
.Update
End With


Next
MsgBox "Added successfully...", vbInformation

rs.Close
db.Close

Set rs = Nothing
Set db = Nothing

End Sub
 

Users who are viewing this thread

Back
Top Bottom