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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help wiwth MS Query Syntax

Status
Not open for further replies.

norrisar

IS-IT--Management
Jul 8, 2005
7
US
The database I am bumping up against expects date as #MM/DD/YYY# how do I use an argument, requesting input from user, for this in MS Query?

Anthony Norris
 
hi,

what database?

yyy? THAT's strange!

How do you EDIT the date that you user enters in a Texbox? NOT a particularly good approch! How about a Date Picker Control?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
First, the date format expected is #MM/DD/YYYY#, my bad. The hashtags are required. I am not positive, but I believe I am working with Oracle as the backend of a Trapeze installation.

I am automating a reporting process using MS Excel as the reporting tool with MS Query pulling the data. If the date range is entered directly into MS Query as ">=20111001 and <=20120630" MS Query automagically converts it to ">=#10/01/2011# and <=#06/30/2012#". However, I want to avoid having to edit the query each time the date range shifts. Like MS Access if I enter ">=[Start Date] and <=[End Date]" in the criteria field MS Query will pop up a dialog requesting the user to enter the appropriate dates. However, I have yet to find a suitable method of resolving the required hashtags. I have tried entering them directly in the dialog box, I have tried concantenating text strings, I have tried text formating functions. Nothing seems to work.

Any ideas?

Anthony Norris
 
I use MS Query a lot! Every day.

I doubt the MS Query will allow a >= PARAMETER.

I would use VBA without even a second thought.

alt+F11 toggles between the sheet and the VB Editor.

In the VB Editor enter this...
Code:
sub Query()
  dim sSQL as string

  with Activesheet.listobjects(1).querytable
     debug.print .commandtext
  end with
end with
then RUN this code to expost your SQL code in the Vide > Immediate Window

Paste back with the SQL that is in your Immediate Window, if you'd like to go that route. It is the best way to include user entered dates and such in the where clause.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top