Excel-export date interval problem

fluidmind

Registered User.
Local time
Today, 14:54
Joined
Jun 30, 2006
Messages
66
Hi!

I'm currently facing a wierd problem, and I really hope you can help me!

I have a query called "fsRapportSalgsoverblik2" which contains a list of all sales made from a company. I want to export that list to excel, which is no problem at all... But when I try to set a date interval, so that only the sales made in a certain period is exported, I get errors. I've tried to implement the interval-limitation in two different ways:

1) Inserting "WHERE date BETWEEN "field A in form" AND "field B in form" in the query from which the data is exported (when using the data-view to view the query output i can see that it works perfectly).

2) Inserting "WHERE date BETWEEN "field A in form" AND "field B in form" in the OnClick-code of the "export to Excel" button, where the export-code is written. So instead of saying:
Code:
Set rst = CurrentDb.OpenRecordset("SELECT * FROM fsRapportSalgsoverblik2;")
I change it to:
Code:
Set rst = CurrentDb.OpenRecordset("SELECT * FROM fsRapportSalgsoverblik2 WHERE date BETWEEN "field A in form" AND "field B in form";")

But no matter which solution I choose, I get the error: "Too few parametres. At least two was expected..." (free translation from danish version of Access). I really don't get it. When exporting to Excel without a date-interval, it works perfectly. But when inserting a date interval, it doesn't work, no matter how I do it....

Please help!!

// JR
 
Your query refers to two fields on your form.
Now if you export your query, it can't find those fields as, apparently, you don't run the export from within your form.
Hence the error message.

Run the export from your form.

RV
 
I don't think I quite follow. How do i "run an export-command from my form". As I understand it, the problem is, that it can't handle values from two different sources (form and query)??? And then the natural conclusion must be to show the data from the query in some hidden fields in the form, and then export the data from the form only... Or am i wrong???
 
I really need some help on this one. I'm kinda stuck... Please!!
 

Users who are viewing this thread

Back
Top Bottom