I'm trying to use a few posts from this forum, including use DoCmd.OutputTo to export a PDF of the current record on a report? to send a single record displayed in a form of my potential client data to a text file to use with Outlook and QuickBooks. I have a button on the form and the following code:
I've spent hours playing with it, but at this point it runs and opens an Excel spreadsheet (I'll turn the AutoStart off once I get everything up and running) with ALL the records displayed. I cannot get it to export the current record only!
I'm sure its something simple, but I can't seem to figure it out. Any ideas?
Thanks
Chip Stewart
Code:
Private Sub Export_Potential_Client_Data_Click() On Error GoTo Err_Export_Potential_Client_Data_Click Dim stDocName As String Dim strOriginalRecordSource As String Dim strNewRecordSource As String stDocName = "Export Potential Client" strOriginalRecordSource = Me.RecordSource strNewRecordSource = "SELECT * FROM [Potential Clients] WHERE [Number] = " & Me![Number] Me.RecordSource = strNewRecordSource DoCmd.OutputTo ObjectType:=acOutputReport, ObjectName:="Export Potential Client Report", OutputFormat:=acFormatTXT, Outputfile:="C:\Clients\Client Data.csv", AutoStart:=True Me.RecordSource = strOriginalRecordSource
I'm sure its something simple, but I can't seem to figure it out. Any ideas?
Thanks
Chip Stewart
Comment