Solved

Custom "between" criteria in Access Query.

Posted on 2008-10-23
6
587 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 1

Author Comment

by:vacnet
ID: 22789802
jamesqu,

Returns "Overflow".
0
 
LVL 9

Accepted Solution

by:
jamesgu earned 500 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

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…

631 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