Hi Experts,
what I've got is already done database with Form, all data are in Listbox, what i need is export filtered data by search boxes to excel files. Is it possible in easy way?
Hi Experts,
what I've got is already done database with Form, all data are in Listbox, what i need is export filtered data by search boxes to excel files. Is it possible in easy way?
the code cycles thru the list box.
the query uses the listbox to pull only data that is selected in the list box (customer name)
the query would look like:
select * from table where [custName]=forms!fMyForm!lstBox
then exports the query data to excel:
Code:sub btnPrintRpts_click() dim vID, vDir , vFile,vCustName dim i as integer vDir = "c:\temp\" for i = 0 to lstBox.listcount -1 vCustName = lstBox.itemdata(i) 'get next item in listbox lstBox = vCustName 'set the listbox to this item vFile = vDir & "Invoice_" & vCustName & ".xls" docmd.TransferSpreadsheet acExport ,acSpreadsheetTypeExcel9,"qsListBoxQry", vFile, true, "Invoice" next end sub
Hi Ranman,
i just recieved error 3011
you didnt show WHERE the err occurred.
nor show any code you are using. Are all your objects named the same as mine?
Can I share with You access file and could You help me somehow add it to an button? Today is first time i am using Access and i completely dont know what to do
Yes send it on
https://file.io/Zc3Uih7CcE38 , i've put it on file.io site cuz in every case my file was too big , isnt it problem?
site doesnt work. just zip the file and upload here.
Sorry for delay, i needed to reduce base, all the time file was too big.
And what i need here in Form to add button, that will download data from Listbox( List20) in excel format
1. your 'criteria boxes' to search should be combo boxes, so user can select the item that already exists.
2. the listbox query should be built (or chosen) when user applies the filter
then you only export the 1 listbox query:
Code:vDir = "c:\temp\" vListName = InputBox("Enter list name", "name list") If vListName = "" Then Exit Sub DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qsListBoxQry", vFile, True, vListName
You're expert so im sure Youre right but i dont know how to use this knowledge