Hi there
I have a 20 character string and I want to get the numbers from position 10 to 14 when they are equal to 5600
I did my access query in design mode as follows but I keep getting syntax errors
NumbA: Mid([fieldname],9,4)
under criteria I put 5600
Could someone please help and tell me what is wrong with that ?
6 1832
== you have wrong criteria..
to get 10 to 14 from string:
but if you want to trap condition, you have to use iif -
iif(mid(string,10,4) like "5600", 5600, string)
-
number inside string is string, so you if put 5600 under criteria, that'll lead you to nowhere since criteria's wrong and data's type wrong.
zmbd 5,501
Expert Mod 4TB
If Paker is only interested in "5600" and not values like "5601" etc, then instead of the Like operand I would use the Equality as the match is specific in nature and will be much faster in data returned.
The only other tweak here is to return either the Null or empty string as the result when the value isn't found at that position as OP only mentioned returning the "5600" value when such is found at that position.
H. didn't mention it; however, you would also use H's solution as a calculated field. The criteria field would not be used with this method.
If this is a query, I would go about it a little different to avoid using an iif(): - SELECT * FROM SomeTable
-
WHERE fieldname LIKE '?????????5600*'
It's not elegant, but I think it will run better/faster.
Thank you all for the suggestions. I will try them out today
zmbd 5,501
Expert Mod 4TB
J, good point and it makes sense if PakerBaker wants the records in their entirety instead of the indicated desired return value of "5600" in the OP. I should have asked about that!
NeoPa 32,556
Expert Mod 16PB
So, there are a number of issues to understand and deal with : - Using
Mid() to get the tenth character onwards requires a second parameter of 10 rather than 9. - The returned value of this calculation would be a string, so criteria would have to be a string too.
- This can be done using
Like in the criteria instead of the Mid() calculation. - A new one - Character positions ten to fourteen would return a five-digit value not a four-digit one.
I'm sure if you deal with all of these issues it'll work fine for you.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jason |
last post by:
I am having trouble using the CONTAINS function in sql
server(enterprise manager). I am typing the following:
Select *
FROM mytable
WHERE CONTAINS(myfield,'mystring')
This returns the...
|
by: moondaddy |
last post by:
I'm running vb.net 1.1 and I need to register a dll using regsvcs.exe and am
getting the error:
Command "RegSvcs.exe" is not valid.
the path to the dll I want to register is:
D:\nwis\Apps\CSLA...
|
by: Lauren Wilson |
last post by:
I'm having trouble with the Access VBA help on my installation of A2K
with Dev tools. Every time I try to retrieve help for items listed in
the Object Browser (and SOME other items as well),...
|
by: Eric |
last post by:
Hi,
I've been trying in vain to get the number of copies a user wants to
print after they've closed the PrintDialog form. Apparantly this value
is sometimes found in the DEVMODE struct for the...
|
by: RML |
last post by:
Hi, I have created a Windows Service which when started, retrieves a file
from an FTP server (running W2K Server) via an FTP call. The service is
"dependant" on
the lanmanworkstation service,...
|
by: tkondal |
last post by:
Hi all.
I just started looking at Python's ctypes lib and I am having trouble
using it for a function.
For starters, here's my Python code:
from ctypes import*;
myStringDLL=...
|
by: Thomas Nelson |
last post by:
I'm trying to write a function that uses function pointers. Here's my
errors:
Board.cc:111: error: expected ',' or '...' before 'p1'
Board.cc:111: error: prototype for 'int Board::play_game(int...
|
by: Ajm113 |
last post by:
Ok, I want to disable any html tags, but the problem is when I do add in the nl2br function with a htmlentities it displays the tags for the <br>! I even keep seeing rn every time I enter a return in...
|
by: GKJR |
last post by:
I have been using Access 2013 (in Office 365) with Windows 8.1 for about a month and a half now. I was a little reluctant to switch from 2010 on Windows 7, but I figured I should try stay ahead of...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |