Code: Select all
Private Sub cmdShow_Click()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String
Dim sList As String
Dim sList1 As String
Dim nIndex As Integer
Application.EnableEvents = False
Application.ScreenUpdating = False
For nIndex = 0 To lst_selectedfields.ListCount - 1
sList = sList & lst_selectedfields.List(nIndex, 0) & ", "
sList1 = sList1 & lst_selectedfields.List(nIndex, 1) & ", "
Next
sList = Left$(sList, Len(sList) - 1)
sList1 = Left$(sList1, Len(sList1) - 1)
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.ace.OLEDB.12.0; " & _
"Data Source=\\se\file\BackEnd.accdb;"
Set rst = New ADODB.Recordset
rst.Open "tblComma", cnn, adOpenKeyset, adLockOptimistic, adCmdTable
With rst
.AddNew
.Fields("Short Serial") = sList
.Fields("Description") = sList1
.Update
End With
rst.Close
cnn.Close
Set cnn = Nothing
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub