Removing first 2 characters from field ?? (1 Viewer)

hessleroader

Hessleroader
Local time
Today, 07:55
Joined
Oct 20, 2008
Messages
14
Hi all,

When I scan a barcode into a field called "product_no#" I am wanting to remove the "1P" element of the part number that has been scanned.

So basically I want this remove after update event?

1PA321354
1P654SD321
1P987ASLJ
1P9875QWD

Any ideas please?

Thanks
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 07:55
Joined
Sep 12, 2006
Messages
15,662
myfield = mid(myfield,3)

just snips the string starting at position 3
 

Minty

AWF VIP
Local time
Today, 07:55
Joined
Jul 26, 2013
Messages
10,371
I would remove the # from your field name, #i is a date delimiter in Access and will end up causing you problems somewhere further down the line

Use something like strProdNo = Right([YourField], Len([YourField] -2))

In other words take the right hand portion of the string that is set to its length - 2

Other string functions https://msdn.microsoft.com/en-us/library/dd789093.aspx
 
Last edited:

missinglinq

AWF VIP
Local time
Today, 02:55
Joined
Jun 20, 2003
Messages
6,423
Either syntax will work, but being lazy, I usually go for the simplest:

Code:
Private Sub product_no#_AfterUpdate()
 Me.product_no# = Mid(Me.product_no#,3)
End Sub
And I'd heed Minty's advice about dropping the #...for just the reason given!

Linq ;0)>
 

Users who are viewing this thread

Top Bottom