Code to delete character after update

D2K2VIC

New Member
Joined
Nov 13, 2003
Messages
25
In my Access DB form, I scan data into a field using a scanner. However, the data contains an extra character, a comma, that needs to be deleted after the field is updated and the focus moves to the next field. This will be the only character that will ever need removal and it is the final character in my data. Any help on the code? Thanks.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Go into the form design, right click the 'barcode' (or whatever you have called it) field -> Properties -> Event Tab -> After Update -> Click the ... button to activate the Builder -> Code Builder -> Ok -> enter this (without the two outermost quotes) "[barcode] = IIf(Right([barcode], 1) = ",", Left([barcode], Len([barcode]) - 1), [barcode])" -> Save and close the VB window -> Save the form.

The code should look like this (before you close the VB window):

Private Sub barcode_AfterUpdate()
[barcode] = IIf(Right([barcode], 1) = ",", Left([barcode], Len([barcode]) - 1), [barcode])
End Sub

But please note that I used the field name 'barcode'

HTH, Andrew. :)
 
Upvote 0

Forum statistics

Threads
1,221,876
Messages
6,162,567
Members
451,775
Latest member
Aiden Jenner

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top