The problem: I cannot copy the results from that list box to the excel sheet. It just copies the first column of the displayed rows in the list box. I had tried using a command button to display the result in the tabular-excel form, but it only takes a pre-defined saved query. I can't save the query as it is generated based on the search key word a user enters in the text box.
How can I display the results in some kind of format that can be copied/ exported to the excel sheet? Can anyone suggest something ?.
My code is :
Expand|Select|Wrap|Line Numbers
- Option Compare Database
- Private Sub List3_BeforeUpdate(Cancel As Integer)
- End Sub
- Private Sub Text0_BeforeUpdate(Cancel As Integer)
- Dim holdVal As String
- holdVal = Me.Text0.Value
- Me.List3.RowSourceType = "Table/Query"
- Me.List3.RowSource = "SELECT * FROM Contents" & _
- " WHERE PART_NUM LIKE '" & holdVal & "*'"
- Me.List3.Requery
- End Sub
Expand|Select|Wrap|Line Numbers
- Private Sub Get_Fields_Click()
- On Error GoTo Err_Get_Fields_Click
- Dim storeVal As String
- storeVal = Me.Text0.Value
- Dim qrRetrieve As String
- qrRetrieve = "SELECT * FROM Contents" & _
- " WHERE PART_NUM LIKE '" & storeVal & "*'"
- DoCmd.OpenQuery qrRetrieve, acNormal, acEdit
- Exit_Get_Fields_Click:
- Exit Sub
- Err_Get_Fields_Click:
- MsgBox Err.Description
- Resume Exit_Get_Fields_Click
- End Sub