473,320 Members | 2,111 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,320 software developers and data experts.

Left function

Hi, I need to take the first letter/letters of a UK postcode and copy it into another field. However, some postcodes are two letters followed by numbers and some are one letter followed by numbers.

How can I make sure that it copies just the letters only?

Thanks

Sally
Sep 17 '10 #1
2 1394
yarbrough40
320 100+
here you go. Assuming you have two text boxes Text0, Text2. This will loop through the characters in Text0 then display only non-integer characters in Text2 Enjoy!

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim s, s2 As String
  3. Dim i As Integer
  4.  
  5. s = Me.Text0.Value
  6.  
  7.     For i = 1 To Len(s)
  8.         If IsNumeric(Mid(s, i, 1)) = False Then
  9.             s2 = s2 & Mid(s, i, 1)
  10.         End If
  11. Next i
  12.  
  13.  Me.Text2.Value = s2
Sep 17 '10 #2
NeoPa
32,556 Expert Mod 16PB
If this is in a QueryDef then something similar to this can be used :
Expand|Select|Wrap|Line Numbers
  1. Left([PCode],IIf(IsNumeric(Mid([PCode],2,1)),1,2))
Sep 17 '10 #3

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

Similar topics

2
by: Luiz Horacio | last post by:
Hi, I want to use the two first numbers of a user-input as a flag, but don't know how to get them in ASP... How can I use a function like 'variable = left(user_input, 2)' in ASP? Regards,
17
by: Nathan Given | last post by:
Hello All, I am trying to debug a broken query. The query uses Left$(,4) instead of Left(,4). What is the difference between the Left() and Left$() functions in Microsoft Access? Thanks!...
2
by: shumaker | last post by:
In an Access Project I have a datasheet with a column of genders, and would like them to display only the first character. Is there a way I can add the Left(string, #) function to a property to...
7
by: Mike | last post by:
I have a program working well. I install it on another computer and i have a problem running the program and it seems related to the Left function. Libraries should be the same on both...
2
by: sorourke1 | last post by:
I am attempting to collect the user's IP address from a Web App. I then need to verify the address is not an 'internal' user. I need to compare the left 3 characters of the IP address with a...
3
by: gonzosez | last post by:
I need to get the first 40 places of a given string. Left(rsVMFG("comments").Value, 40) produces an error The error says Left() as integer
22
Dököll
by: Dököll | last post by:
Hiya, Partners! I have been into it for 12 hours straight this week-end, my son is very unhappy. Looks like I am getting pretty close but need your help, Again. I will post my first...
3
by: philelpko | last post by:
Morning all, Wondering if anyone can help me out with this one? I have a "Add User" form to add a new users information tel, mob etc. One field is the persons full name. What I am trying to...
32
by: Greg | last post by:
I know I can use the Microsoft.VisualBasic.Left function to get the left portion of a string, but I would prefer to avoid using any Microsoft.VisualBasic namespace items. What is the equivilant in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.