Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Syntax?

Status
Not open for further replies.

Ktx7ca

IS-IT--Management
Apr 5, 2008
88
CA
I have this query

SELECT Book.BookNumber
FROM Book
WHERE (((Book.DateUpdated) Between [Forms]![INS-Export]![EXPLastDate] And [Forms]![INS-Export]![EXPNow]) AND ((Book.Status)="Sold"));

when I run it it works just fine , but when I use this Code in a button on the same form. it asks me to entry the dates.

Application.ExportXML acExportQuery, "Export Sold", " C:\Export\TestSold.xml"

I'm sure I'm missing something simple.

any ideas greatly apreciated
 

You may need delimiters around the date fields.
Something like this?
Code:
Between [b][COLOR=red]#[/color][/b][Forms]![INS-Export]![EXPLastDate][b][COLOR=red]#[/color][/b] And [b][COLOR=red]#[/color][/b][Forms]![INS-Export]![EXPNow][b][COLOR=red]#[/color][/b]

Randy
 
Hi Randy

Thanks for the help, I was sure I had tried that before, but on trying it now I get

The Expression you have entered has an invalid date value


 

Try adding a Debug.Print line to your code and find out exactly what you have.

Randy
 
HI the Error happens before I run any code, It occurs when I try and save the query

 
Alvechurchdata,Thats what I was thinking, heres the SQL Now

SELECT Book.BookNumber
FROM Book
WHERE (((Book.DateUpdated) Between #[Forms]![INS-Export]![EXPLastDate]# And #[Forms]![INS-Export]![EXPNow]#) AND ((Book.Status)="Sold"));


 

And what value is in the criteria section of your query grid?


Randy
 
I'm not sure I totally understand your Question but in the

DateUpdated Criteria: Between #[Forms]![INS-Export]![EXPLastDate]# And #[Forms]![INS-Export]![EXPNow]#

and the Sold Criteria: "Sold"

with the # in place I can't save or change to datasheet view

 

Are you showing us the code from the query or from the button? We need to see the button code.


Randy
 
Hi Randy

The button code has not changed as is in my first post

Application.ExportXML acExportQuery, "Export Sold", " C:\Export\TestSold.xml"

 
I got this working by running the SQL in code

Thanks for everyones Help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top