473,382 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Trying to find text within a text string

Faz
I am trying to extract text before a certain character appears in a
string. This character is the letter "C".

Here is some sample data - the field is called REFERENCE_2:

REFERENCE_2
10299C17264
9841C17218

I want to extract 10299 for the first line and 9841 for the second
line into a SQL query. I am trying to use the FIND function so I can
get the position of C and do a MID function on this position from the
first character to the position of C - 1, but FIND does not work in
the query builer screen.

I am not proficient with VB and want to use the normal query
functionality.

Many thanks.
Nov 13 '05 #1
2 35675
MyNumber = Left([Reference_2],Instr([Reference_2],"C")-1)
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Faz" <af*****@hotmail.com> wrote in message
news:26************************@posting.google.com ...
I am trying to extract text before a certain character appears in a
string. This character is the letter "C".

Here is some sample data - the field is called REFERENCE_2:

REFERENCE_2
10299C17264
9841C17218

I want to extract 10299 for the first line and 9841 for the second
line into a SQL query. I am trying to use the FIND function so I can
get the position of C and do a MID function on this position from the
first character to the position of C - 1, but FIND does not work in
the query builer screen.

I am not proficient with VB and want to use the normal query
functionality.

Many thanks.

Nov 13 '05 #2
af*****@hotmail.com (Faz) wrote in message news:<26************************@posting.google.co m>...
I am trying to extract text before a certain character appears in a
string. This character is the letter "C".

Here is some sample data - the field is called REFERENCE_2:

REFERENCE_2
10299C17264
9841C17218

I want to extract 10299 for the first line and 9841 for the second
line into a SQL query. I am trying to use the FIND function so I can
get the position of C and do a MID function on this position from the
first character to the position of C - 1, but FIND does not work in
the query builer screen.


I believe that Find() is an Excel function - in Access VBA you should use
the InStr() function to retrieve the position of another substring (in
Access 2000 and newer).

Something like this in a query's Field row:

FirstPart: Left$([REFERENCE_2], InStr([REFERENCE_2], "C") - 1)

assuming the REFERENCE_2 never has a Null value - otherwise you'll need to
use the Nz() function or the IIF() function to handle that possibility.

- John Mishefske
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chuck Haeberle | last post by:
I have an interesting regular expression challenge for someone more experienced with them than I for a data layer class... I need an expression to search a SQL statement (any type, SELECT INSERT...
7
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current...
12
by: Phil Certain | last post by:
Hi, I'm trying to do something very simple...or at least it should be. I have created a host page (gen.aspx) and a very simple user control (us.ascx). The corresponding code-behind files are...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
5
by: Mike Labosh | last post by:
In VB 6, the Form_QueryUnload event had an UnloadMode parameter that let me find out *why* a form is unloading, and then conditionally cancel the event. In VB.NET, the Closing event passes a...
1
by: Karen | last post by:
I am very new to MySQL- I currently have an VBA module using a VBSCript that will find different aspects of a text string that are a unique text string and turn it into a not so unique text string....
1
by: vmoreau | last post by:
I have a text and I need to find a Word that are not enclosed in paranthesis. Can it be done with a regex? Is someone could help me? I am not familar with regex... Example looking for WORD:...
6
by: HONOREDANCESTOR | last post by:
Suppose I have a dll which might be installed in the directory c: \MyClass\. I want to be able to find the path of this dll from within the dll. In other words, I want a function that can return...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.