Solved Export from Ms Access form in to Excel (1 Viewer)

skdn71

New member
Local time
Today, 18:39
Joined
Jul 23, 2023
Messages
22
Hello,

Could you please help how to exporting search results in to xlsx file, with below vba i get empty result on excel

see attachement
Code:
Private Sub Command91_Click()
DoCmd.OutputTo acOutputForm, "Listproduct", acFormatXLSX, "C:\Data\export.xlsx", True
End Sub

Private Sub txtSearch_KeyUp(KeyCode As Integer, Shift As Integer)
    Me.frmlistprod.Form.Filter = "[ItemCode]Like '*" & Me.txtSearch.Text & "*' or" _
    & "[ItemDescription]Like '*" & Me.txtSearch.Text & "*' or" _
    & "[PPU]Like '*" & Me.txtSearch.Text & "*'"
    Me.frmlistprod.Form.FilterOn = True
End Sub
 

Attachments

  • Result export.jpg
    Result export.jpg
    80.7 KB · Views: 24
  • Product.jpg
    Product.jpg
    104.8 KB · Views: 23
  • form.jpg
    form.jpg
    112.5 KB · Views: 28
  • Product.accdb
    4.2 MB · Views: 21

theDBguy

I’m here to help
Staff member
Local time
Today, 09:39
Joined
Oct 29, 2018
Messages
21,485
Check out Excel automation and the CopyFromRecordset method.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 17:39
Joined
Jul 9, 2003
Messages
16,285
First you need to turn your filter into a query and then you can use B tab development code here:-


I also have several blogs demonstrating the above code on my website:-

 

Gasman

Enthusiastic Amateur
Local time
Today, 17:39
Joined
Sep 21, 2011
Messages
14,338
Look at TransferSpreadSheet perhaps?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:39
Joined
May 7, 2009
Messages
19,247
here try your export form.
 

Attachments

  • Product.accdb
    4.2 MB · Views: 38

Users who are viewing this thread

Top Bottom