473,385 Members | 1,780 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,385 software developers and data experts.

Query Update Separate String from Number

eclypz
10
Hello,

I need some help...

I have a db, that contains two tables (tblAgents; tbl Service), the tblAgents, have one column with the username, and the username can be something like: XPT001 until XPT400; ZDTR01 until ZDTR25; PPTXR0001 until PPTXR1000.

In this table i want to add a column that contains only the initials of the user in the line, for example: XPT; ZDTR; PPTXR...

I'm having troubles to implement an update query that could help me in this task. In excell i use this: LEFT(A1,MIN( FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))-1).

But now i need something like this but in access because the quantity of records that i need to work.

can any one help me with this?

thanx,
Feb 18 '08 #1
1 1639
Stewart Ross
2,545 Expert Mod 2GB
Hello,

I need some help...

I have a db, that contains two tables (tblAgents; tbl Service), the tblAgents, have one column with the username, and the username can be something like: XPT001 until XPT400; ZDTR01 until ZDTR25; PPTXR0001 until PPTXR1000.

In this table i want to add a column that contains only the initials of the user in the line, for example: XPT; ZDTR; PPTXR...

I'm having troubles to implement an update query that could help me in this task. In excell i use this: LEFT(A1,MIN( FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))-1).

But now i need something like this but in access because the quantity of records that i need to work.

can any one help me with this?

thanx,
Hi eclypz. Here is a simple string function which will extract the non-numeric characters from your string and return them. It relies on the ASCII ordering of characters, where 0-9 are lower in code value than all alphabetic characters in the characterset. It won't be quite as fast as the Excel function; if this is an issue I'm sure there are other, faster methods available.

To use it, copy the code below into any general code module in your database, and in whatever query you are building to view the fields of your base tables add a column with a field name referring to the function, like this:

UserInitials: ExtractAlpha([username])

Expand|Select|Wrap|Line Numbers
  1. Public Function ExtractAlpha(StringIn As String) As String
  2.     'Extracts and returns the non-numeric characters from a string
  3.     Const AsciiNine = 57
  4.     Dim ChVal As Integer, Ch As String
  5.     Dim Extracted As String, N As Integer, I As Integer
  6.     N = Len(StringIn)
  7.     For I = 1 To N
  8.         Ch = Mid$(StringIn, I, 1)
  9.         ChVal = Asc(Ch)
  10.         If ChVal > AsciiNine Then
  11.             Extracted = Extracted & Ch
  12.         End If
  13.     Next I
  14.     ExtractAlpha = Extracted
  15. End Function
  16.  
  17.  
Regards

Stewart
Feb 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: lawrence | last post by:
A very strange bug. www.monkeyclaus.org is run by a cms I'm developing. One of types of users we allow is "justTestingTheSite", a type of user I developed to give demo's to prospective clients. The...
2
by: Dom | last post by:
I need to run a query based on a query in Access. The second query has a number of conditions which all work well, but there is one more contition I need to set to make it run properly. the...
0
by: Dalan | last post by:
I'm not certain if this is doable in the manner explained below, but I'm certain that there have been Access developers who have done something similar. So whatever insight and assistance that can...
15
by: Rolan | last post by:
There must be a way to enhance the performance of a query, or find a plausible workaround, but I seem to be hitting a wall. I have tried a few tweaks, however, there has been no improvement. ...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
5
by: teddysnips | last post by:
I have to write an application to do some data cleansing. It's a Contact database, but over a number of years there are multiple companies which are all essentially the same entity. For each...
36
by: Liam.M | last post by:
hey guys, I have one last problem to fix, and then my database is essentially done...I would therefore very much appreciate any assistance anyone would be able to provide me with. Currently I...
6
by: Dixie | last post by:
I have asked this question before, but I could not get the suggested solution work. So I will give more details this time. I have an append query that adds several hundred records to a table...
1
by: jmarcrum | last post by:
Hey everyone, I have a question that's been troubling me for a bit. I work for Alabama Power. I have 1 table (tblOutages). Every morning I import a list of Power Outages for the state of...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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 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.