corinereyes
New member
- Local time
- Today, 23:46
- Joined
- Mar 3, 2013
- Messages
- 12
Hi Guys,
Can someone please help me figure out how to filter records from a table based from a selected item in a combo box and export the results to excel. I have started this code and im so lost.
Thank you in advance.
Regards,
Corine
Can someone please help me figure out how to filter records from a table based from a selected item in a combo box and export the results to excel. I have started this code and im so lost.
Thank you in advance.
Regards,
Corine
Code:
Private Sub cmdSaveRecords_Click()
Dim StrSQL As String
Dim qdf As QueryDef
'On Error GoTo Err_cmdSaveRecords_Click
StrSQL = "SELECT * FROM [QueryResults] WHERE [QueryResults].[Contract type] Not like *NON MEDICAL*"
If MsgBox("Do you want to save the current records?", vbOKCancel) = vbOK Then
DoCmd.TransferSpreadsheet acExport, , "QueryResults", "\\kfafhstore\DEPTS\PERSONNEL\CORINE\EVALUATION PROJECT\B Database file\Test1.xlsx", True
MsgBox "Records sucessfully save.", vbInformation, "Save Records"
End If
Exit_cmdSaveRecords_Click:
Exit Sub
'Err_cmdSaveRecords_Click:
'MsgBox Err.Description
'Resume Exit_cmdSaveRecords_Click
End Sub