472,780 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 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 35611
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)...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.