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!

Specifying Defaults in an SQL statement

Status
Not open for further replies.

billheath

Technical User
Mar 17, 2000
299
US
I am using the following sql querry:
"SELECT Funds.Date, Funds.Trak FROM Funds WHERE (((Funds.Date) Between [Beggining Date?] And [Ending Date?]) AND ((Funds.Account)="IRA")) ORDER BY Funds.Date;"

[Beggining Date] and [Ending Date] are supplied by the user when the querry is run. I would like to specify defaults:

[Beginning Date] = 1/1/2002
[Ending Date] = Now()
Can this be done in the sql statement? Or is there another method?
Thanks,
Bill
 
Sure, just put it in a string and concat in the beginning and ending date. Be sure to use # to tell jet it is a date field (if that is what it is).

ex.strSQL = "SELECT Funds.Date, Funds.Trak FROM Funds WHERE (((Funds.Date) Between #" & BegginingDate & "# And #" & EndingDate & "# AND ((Funds.Account)="IRA")) ORDER BY Funds.Date;"

or just put Now() where EndingDate is.

There you go.

m6
 
M6, I know I can put the actual dates in and the querry will run. I want the user to be able to enter his on beggining and ending dates with defaults that he can select if appropriate.

As is, a pop-up box asks for each date with no default.
Thanks,
Bill
 
Hi Heathco:

Try this:

"SELECT Funds.Date, Funds.Trak FROM Funds WHERE (((Funds.Date) Between DateValue([Enter Begin Date]) And DateValue([Enter End Date]) AND ((Funds.Account)="IRA")) ORDER BY Funds.Date;"

I hope this is helpful

MichHart " Never regret yesterday because it cannot be changed;
Instead make sure today does not become a regret of tomorrow."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top