Filter records in table based from an item from Combox box

corinereyes

New member
Local time
Today, 11:50
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. :confused:

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
 
Hi Corine. Welcome to the forum. You can create a query with a form reference in the criteria and then use TransferSpreadsheet on said query.
 
Hi Corine. Welcome to the forum. You can create a query with a form reference in the criteria and then use TransferSpreadsheet on said query.

Hi DBguy,

Thank you :)

Can you please just show me how to start on it? maybe a sample code?
 
Hi Again DBGuy,

From your suggestion i think i figure it out :) i will get back if i will encounter some problems :)

Thank you!
 
Hi Again DBGuy,

From your suggestion i think i figure it out :) i will get back if i will encounter some problems :)

Thank you!
Hi. Glad to hear you made some progress. Let us know if you get stuck. Good luck!
 

Users who are viewing this thread

Back
Top Bottom