?
Solved

Custom "between" criteria in Access Query.

Posted on 2008-10-23
6
Medium Priority
?
593 Views
Last Modified: 2013-11-29
Looking to retrieve all values between records listing AA-1 through AA-96 (ie. between "AA-1" and "AA-96"). Since its not a whole number, I assume it won't retrieve the exact values I'm looking for.
0
Comment
Question by:vacnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 9

Expert Comment

by:jamesgu
ID: 22789167
try this

select * from <table_name>
where convert(int, replace(<your_column_name>, 'AA-', ''))  between 1 and 96;

0
 
LVL 1

Author Comment

by:vacnet
ID: 22789246
jamesqu,

Returns "Undefined function 'convert' in expression.
0
 
LVL 9

Expert Comment

by:jamesgu
ID: 22789436
select * from <table_name>
where CInt(replace(<your_column_name>, 'AA-', ''))  between 1 and 96;

0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 1

Author Comment

by:vacnet
ID: 22789802
jamesqu,

Returns "Overflow".
0
 
LVL 9

Accepted Solution

by:
jamesgu earned 2000 total points
ID: 22789821
i think you have some values other than 'AA-???' in the table, if you don't want those records,

do

select * from <table_name>
where CInt(replace(<your_column_name>, 'AA-', ''))  between 1 and 96
and <your_column_name> like 'AA-*'


0
 
LVL 1

Author Closing Comment

by:vacnet
ID: 31509336
Works perfectly! Thank you jamesqu.
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

718 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