Search results into Excel

caferacer

Registered User.
Local time
Today, 19:13
Joined
Oct 11, 2012
Messages
96
Hi All,

I have a search form which uses the Allen Browne code from here http://allenbrowne.com/ser-62.html.

The data I have linked to my form which the above code is using is from an Union query and the search generates the correct results.

I have used code from here http://btabdevelopment.com/export-tablequery-to-excel-to-new-named-sheet/ but it only exports all records from the Union query not just the results from the search, which is what I want to achieve. This maybe because you can’t use a Union query in this way.

How can I get the filter results from the Allen Browne code into the export to excel module/function?

Thanks.

Mark
 
Hi,

Thanks for that.

However it falls over at the line in the attached file?

Does this suggest the recordset doesn't exist as the code would normally expect to see it? Is the filtered recordset not stored in the same way, therefore the export code doesn't recognise it?

I don't have enough knowledge to be able to diagnose so any help is much appreciated?

Thanks
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    98.5 KB · Views: 102
you did not copy exactly what was in the code.

Code:
...
 For Each fld In rst.Fields
        ApXL.ActiveCell = fld.Name
        ApXL.ActiveCell.Offset(0, 1).Select
    Next
    rst.MoveFirst
    xlWSh.Range("A2").CopyFromRecordset rst
...

the line rst.MoveFirst should be on the next line

JR
 

Users who are viewing this thread

Back
Top Bottom