[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Trying to specify a range with sql string and vba variables

Posted on 2010-01-06
3
Medium Priority
?
233 Views
Last Modified: 2012-05-08
Hi,
instead of just
"Select * From invoices Where [Invoice Date] >= #" & myval & "#"
I would like:
"Select * From invoices Where [Invoice Date] >= #" & myval & "#" & <= myval2 and ... , is there some command program that could give me the correct syntax for any sql string - if not could anyone give me the correct syntax for the above.
0
Comment
Question by:Jimmy_inc
3 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 1000 total points
ID: 26195651
I believe it would be something like this:

"Select * From invoices Where [Invoice Date] >= #" & myval & "# AND [Invoice Date] <= #" & myval2 & "#"

Just build the sql string, then replace the parts with variables making sure your & and your " are matching.

Thomas
0
 
LVL 22

Assisted Solution

by:Kelvin Sparks
Kelvin Sparks earned 1000 total points
ID: 26195753
You can also use
"Select * From invoices Where [Invoice Date] BETWEEN #" & myval & "# AND #" & myval2 & "#"
 
Kelvin

 
0
 

Author Closing Comment

by:Jimmy_inc
ID: 31673778
Thanks worked perfectly.

 Im going to post another question for you guys
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question