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

Alphabets in a field

171 100+
Hi
Pls anyone can help me to find only the alphabets from a field in MS ACCESS
eg. if the field is abcd123 i need to retrieve only abcd
Pls help.....
Jun 12 '07 #1
5 1785
missinglinq
3,532 Expert 2GB
What you need to do is to loop thru your original string one character at a time and keep the character if it is not numereic. This will do it:

Expand|Select|Wrap|Line Numbers
  1. Dim OldString As String
  2. Dim NewString As String
  3. NewString = ""
  4. OldString = "ab9cd12e3"
  5.  
  6. For I = 1 To Len(OldString)
  7.   If Not IsNumeric(Mid(OldString, I, 1)) Then
  8.      NewString = NewString & (Mid(OldString, I, 1))
  9.   End If
  10. Next I 
  11.  
Good Luck!
Jun 12 '07 #2
rajeevs
171 100+
Hi
Thanks for the reply. But I want to use it in a query. the query need to retrieve the the data without the numbers from the table field
eg: if the field contains records with alphabets and numbers i need to get the result of query as only alphabets
ie; abcd123, ghi2333, foxwer1 results should be abcd, ghi, foxwer like that
please help...

Thank you
Jun 14 '07 #3
rajeevs
171 100+
Hi
Thank u for the kind reply. But i tried that code. i will explain what i am doing. i have a database and the main table got a field which holds records like abcd1234, ghj36789. i want to create a new table using a module with a single field that should have only the alphabet part of the main table like abcd, ghj.
i can create a table using a module, but i tried your code but no effect.
Hope you can help me pls..........

Thank u
Jun 21 '07 #4
JKing
1,206 Expert 1GB
Hi, I added to the previous code posted to help you loop through the main table and store the new strings into your second table. Make sure you have the second table created with the single field before attempting this.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdRun_Click()
  2.     Dim OldString As String
  3.     Dim NewString As String
  4.     Dim rstAlpha As Recordset
  5.     Dim rstAlphaNum As Recordset
  6.     Dim I As Integer
  7.  
  8.     Set rstAlpha = CurrentDb.OpenRecordset("tblAlpha", dbOpenDynaset)
  9.     Set rstAlphaNum = CurrentDb.OpenRecordset("tblAlphaNum", dbOpenDynaset)
  10.  
  11.     rstAlphaNum.MoveFirst
  12.  
  13.     Do While rstAlphaNum.EOF = False
  14.         OldString = rstAlphaNum![alphaNum]
  15.         NewString = ""
  16.         For I = 1 To Len(OldString)
  17.           If Not IsNumeric(Mid(OldString, I, 1)) Then
  18.              NewString = NewString & (Mid(OldString, I, 1))
  19.           End If
  20.         Next I
  21.         rstAlpha.AddNew
  22.         rstAlpha![alpha] = NewString
  23.         rstAlpha.Update
  24.         rstAlphaNum.MoveNext
  25.     Loop
  26. End Sub
  27.  
Notes:
tblAlphaNum is your main table and [alphaNum] is the field containing your alpha numeric code
tblAlpha will be your second table and [alpha] is the field you want to store your new alpha codes in

Hope this helps set you in the right direction.
Jun 21 '07 #5
rajeevs
171 100+
Thank u so much
It works

Raj
Jun 26 '07 #6

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

Similar topics

5
by: Reddy | last post by:
There is a table name "testtable". This table has three columns col1(char), col2(int) and col3(char). The data in the table will be as mentioned below: ------------------------------------------...
4
by: Ben | last post by:
Hi all, In my STUDENT table, I have a field called STUDENT_NAME. I want the data in this field to be only alphabets with allowance for ' and - ,but nothing else- no digits, no other special...
5
by: salo | last post by:
hi... can anybody help me for displaying only alphabets in textboxes in visual studio 2005 i gave in validation expression for regular expression validation...... but still im not getting ....if i...
1
by: rajeevs | last post by:
Hi I have posted earlier about the same but only one reply thanks but i dont know how to do that. Please help again i will explain what i need to do in ms access by using a query i want to trim...
3
missshaikh
by: missshaikh | last post by:
i need to make a query Sort by alphabets "D" or Sort by alphabets "E" means Sort by A B C D E F G H I J K L M N O P Q R S T U V W X Y Z All
17
nitindel
by: nitindel | last post by:
Hi All, I have a text box and want to validate it like this: I want to enter Numerics or alphanumerics in the text box but not Alphabets alone.If Alphabets alone entered then...
1
by: sury | last post by:
I want to split a word into individual alphabets and substitute a word for each of the alphabets in c#. example: If the word entered is LATE, the output wud be L:London A :Apple T:Tom E:Egg
1
by: meeanji | last post by:
Hi friends, i need to write validation for textbox(Usernme ) which should accept only alphabets. I am able throw validation that Please fill the UserName Details.Now it should throw that it accepts...
7
by: prigupta2 | last post by:
i want to type Alphabets and numbers in text box in such a way first alphabets then number ex C102 M458 only CM0123456789 please provide code in vb6.0
4
by: rajeevs | last post by:
Hi Previously I asked this question and I got the answer from the moderator. I am getting all the alphabets, but now i want to get the alphabets before the first occurance of numeric value. I am...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...

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.