Code: Select all
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
ListBox2.AddItem ListBox1.List(ListBox1.ListIndex)
End Sub
Code: Select all
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
ListBox2.AddItem ListBox1.List(ListBox1.ListIndex)
End Sub
Code: Select all
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Long
Dim j As Long
Dim k As Long
k = ListBox1.ListIndex
' Add item to list box
ListBox2.AddItem ListBox1.List(k)
i = ListBox2.ListCount - 1
' Add columns
For j = 1 To 4
ListBox2.List(i, j) = ListBox1.List(k, j)
Next j
End Sub
Code: Select all
Private Sub txtSearch_AfterUpdate()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String
Dim ws As Worksheet
Set ws = Worksheets("Orders")
ws.Range("A2:O10000").ClearContents
Application.ScreenUpdating = False
Application.EnableEvents = False
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.ace.OLEDB.12.0; " & _
"Data Source=E:\P\Database.accdb;"
Set rst = New ADODB.Recordset
strSQL = "SELECT [H Code],[T Code],[Department N],[P Name],[L Total] FROM Orders WHERE [Serial No]=" & Me.txtSearch.Value
rst.Open strSQL, cnn, adOpenKeyset, adLockOptimistic, adCmdText
ws.Range("A2").CopyFromRecordset rst
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
ListBox2.RowSource = "Data"
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Code: Select all
ListBox2.AddItem ListBox1.List(k)
Code: Select all
ListBox2.Column = rst.GetRows
Code: Select all
ws.Range("A2").CopyFromRecordset rst
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
ListBox2.RowSource = "Data"