Put it behind the command button you want the user to press.
Your screen, if it's bound, will have a table or a query behind it, by that I mean the information on the screen will be coming from a query or a table. You'll be displaying the person's last name, first name, etc information in textboxes on this screen.
So what you want to do is take the information in the text boxes, filter the query, and export the filtered information to Excel. Lets say the screen is bound to a query named [qryEmployees] and the text boxes are called txtFirst and txtLast.
Dim sSQL as String
sSQL = "SELECT * FROM [qryEmployees] WHERE [Firstname] = '" & txtFirst.Value & "' AND [Lastname] = '" & txtLast.Value & "';"
DoCmd.TransferSpreadsheet acExport, 3, sSQL,"C:\Exported.xls", True, "A1:G12"
www.dsmyth.net/blog |