Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 17th, 2007, 10:21 AM
Registered User
 
Join Date: Nov 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default WHERE date > n; n = #10/26/2007#

Hi Everyone

I need an SQL statement where a variable will control WHERE clause

For instance

SQLstr = "SELECT * FROM tblJob WHERE Date > #10/26/2007#;" it works

but I want to use a variable instead of the date.

Something like this
n = #10/26/2007#
SQLstr = "SELECT * FROM tblJob WHERE Date > n;"

Is it feasible?


 
Old November 17th, 2007, 02:10 PM
Registered User
 
Join Date: Oct 2006
Location: Leigh, Lancashire, United Kingdom.
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

This should work

SQLstr = "SELECT * FROM tblJob WHERE Date > #" & n & "#"
 
Old November 17th, 2007, 03:59 PM
Registered User
 
Join Date: Nov 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks
:)

 
Old November 20th, 2007, 09:00 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Actually, since Date() is an Access function, it really should be taken OUTSIDE the quotes, that is...

SQLstr = "SELECT * FROM tblJob WHERE [n] < #" & Date() & "#"

where n is a field in the table. Note: If Date is a field you made up, then change its name. Date() is an Access function, and having a field with the same name will cause problems.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division




Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i convert date into format '2007-10-25T11: vishnu108mishra C# 2 November 23rd, 2007 04:45 AM
Help needed - data from Excel sht where Date>= xx pandasum Visual Basic 2005 Basics 0 August 19th, 2007 11:34 PM
want to convert date from 01/12/07 to 12-Jan-2007 hurperl Perl 1 April 12th, 2007 05:47 AM
Chpt 7 >> Pg 245 >>Try It Out #4-5 harrison4411 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 March 2nd, 2006 06:26 PM
* where date >= '"& dateVar &"' order by date wrofox Classic ASP Databases 5 February 24th, 2005 10:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.