Removing first 2 characters from field ??

hessleroader

Hessleroader
Local time
Today, 16:03
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
 
myfield = mid(myfield,3)

just snips the string starting at position 3
 
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:
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

Back
Top Bottom