473,473 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Alphabets in a field

171 New Member
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 posting the previous procedure here.
If i run through the example like,

abcd123gh
The answer is abcdgh.
But I want to get the result as abcd. Please help me. Thank you for the support always provided by you all.

My earlier post title was Alphabets in a field and the procedure given by Jking
The procedure was

Private Sub cmdRun_Click()
Dim OldString As String
Dim NewString As String
Dim rstAlpha As Recordset
Dim rstAlphaNum As Recordset
Dim I As Integer

Set rstAlpha = CurrentDb.OpenRecordset("tblAlpha", dbOpenDynaset)
Set rstAlphaNum = CurrentDb.OpenRecordset("tblAlphaNum", dbOpenDynaset)

rstAlphaNum.MoveFirst

Do While rstAlphaNum.EOF = False
OldString = rstAlphaNum![alphaNum]
NewString = ""
For I = 1 To Len(OldString)
If Not IsNumeric(Mid(OldString, I, 1)) Then
NewString = NewString & (Mid(OldString, I, 1))
End If
Next I
rstAlpha.AddNew
rstAlpha![alpha] = NewString
rstAlpha.Update
rstAlphaNum.MoveNext
Loop
End Sub
Jul 10 '09 #1
4 1421
OldBirdman
675 Contributor
Change:
Expand|Select|Wrap|Line Numbers
  1. For I = 1 To Len(OldString) 
  2. If Not IsNumeric(Mid(OldString, I, 1)) Then 
  3. NewString = NewString & (Mid(OldString, I, 1)) 
  4. End If 
  5. Next I 
  6.  
To:
Expand|Select|Wrap|Line Numbers
  1. For I = 1 To Len(OldString) 
  2. If Not IsNumeric(Mid(OldString, I, 1)) Then 
  3. NewString = NewString & (Mid(OldString, I, 1)) 
  4. Else
  5. Exit For
  6. End If 
  7. Next I 
  8.  
Jul 10 '09 #2
rajeevs
171 New Member
Great. It works perfect
Thank You So much for the prompt help.
Jul 10 '09 #3
ADezii
8,834 Recognized Expert Expert
@rajeevs
Using similar logic:
Expand|Select|Wrap|Line Numbers
  1. Dim strNewString As String
  2. Dim rstAlpha As Recordset
  3. Dim rstAlphaNum As Recordset
  4. Dim I As Integer
  5.  
  6. CurrentDb.Execute "DELETE * From tblAlpha", dbFailOnError
  7.  
  8. Set rstAlpha = CurrentDb.OpenRecordset("tblAlpha", dbOpenDynaset)
  9. Set rstAlphaNum = CurrentDb.OpenRecordset("tblAlphaNum", dbOpenDynaset)
  10.  
  11. With rstAlphaNum
  12.   Do While .EOF = False
  13.     strNewString = ""
  14.       For I = 1 To Len(![alphaNum])
  15.         If Not IsNumeric(Mid(![alphaNum], I, 1)) Then
  16.           strNewString = strNewString & (Mid(![alphaNum], I, 1))
  17.         Else
  18.           If strNewString <> "" Then
  19.             rstAlpha.AddNew
  20.               rstAlpha![alpha] = strNewString
  21.             rstAlpha.Update
  22.           End If
  23.             .MoveNext
  24.             Exit For
  25.         End If
  26.       Next I
  27.   Loop
  28. End With
  29.  
  30. rstAlphaNum.Close
  31. rstAlpha.Close
  32. Set rstAlphaNum = Nothing
  33. Set rstAlpha = Nothing
  34.  
P.S. - I did not include Comments so as to not lengthen the code, but should you have any questions, please feel free to ask.
Jul 11 '09 #4
rajeevs
171 New Member
Thank you very much once agin for the support
Jul 12 '09 #5

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

Similar topics

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...
5
by: rajeevs | last post by:
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.....
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
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
Oralloy
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,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.