Hey all. I have a form I use to display results from a search. There is a text box, someone enters in a keyword, then click Search and it then displays every record with that keyword individually. Meaning, if 5 records match, the form shows the first record and then I have a Next and Back button that the user can use to view each record.
I'd like to export those records obtained from the Search to an Excel file.
Here is the code I have for the Search (which is admittedly borrowed from another site I believe):
Code:
Private Sub cmd_SearchbyCompID_Click()
Dim strsearch As String
Dim Task As String
'Check if a keyword entered or not
If IsNull(Me.txt_SearchOne) Or Me.txt_SearchOne = "" Then
MsgBox "Please type in your search keyword.", vbOKOnly, "Keyword Needed"
Me.txt_SearchOne.BackColor = vbYellow
Me.txt_SearchOne.SetFocus
Else
strsearch = Me.txt_SearchOne.Value
Task = "SELECT * FROM tbl_Exceptions WHERE ((Exception_ID Like ""*" & strsearch & "*""))"
Me.RecordSource = Task
Me.txt_SearchOne.BackColor = vbWhite
End If
End Sub
Is there any way to do this by adding a single button? After my attempts, the process has become complex and isn't efficient at all for the target audience of the form. Any help is appreciated. Thanks!