A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Triming a letter from barcode..



 
 
Thread Tools Display Modes
  #1  
Old October 9th, 2008, 02:56 PM posted to microsoft.public.access
GregB
external usenet poster
 
Posts: 115
Default Triming a letter from barcode..

On the boxes I have come in an extra "S" is inlcuded on in the barcode when
compared to the barcode on the item itself.
I scan stuff in by the box and scan stuff out by the item

I am trying to set an onclose event on a form utilizing vba to trim of the
"s" if there is an "s"

the field is called barcode
I know to use an IFF statement but can not get it right..
What would the code look like?

Thanks!
  #2  
Old October 9th, 2008, 03:05 PM posted to microsoft.public.access
Rick Brandt
external usenet poster
 
Posts: 4,354
Default Triming a letter from barcode..

GregB wrote:
On the boxes I have come in an extra "S" is inlcuded on in the
barcode when compared to the barcode on the item itself.
I scan stuff in by the box and scan stuff out by the item

I am trying to set an onclose event on a form utilizing vba to trim
of the "s" if there is an "s"

the field is called barcode
I know to use an IFF statement but can not get it right..
What would the code look like?

Thanks!


Form Close is the wrong event. Either use AfterUpdate of the control or
BeforeUpdate of the form.

If Right(Me.BarCode,1) = "S" Then
Me.BarCode = Left(Me.BarCode, Len(Me,Barcode)-1)
End If

Extra characters on the end of a barcode are usually check-digits and for
your scanner to "see" them as characters in the output it would have to be
set up for the wrong barcode type. Also, check-digits are seldom always the
same character so your logic might not work as you expect.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


  #3  
Old October 9th, 2008, 03:05 PM posted to microsoft.public.access
Allen Browne
external usenet poster
 
Posts: 11,706
Default Triming a letter from barcode..

The Close event of the form is too late.
Use the AfterUpdate event procedure of the text box.

Something like this:

Private Sub barcode_AfterUpdate()
If Me.barcode Like "?*S" Then
Me.barcode = left(Me.barcode, len(Me.barcode) - 1)
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"GregB" wrote in message
...
On the boxes I have come in an extra "S" is inlcuded on in the barcode
when
compared to the barcode on the item itself.
I scan stuff in by the box and scan stuff out by the item

I am trying to set an onclose event on a form utilizing vba to trim of the
"s" if there is an "s"

the field is called barcode
I know to use an IFF statement but can not get it right..
What would the code look like?

Thanks!


  #4  
Old October 9th, 2008, 04:16 PM posted to microsoft.public.access
Klatuu[_3_]
external usenet poster
 
Posts: 396
Default Triming a letter from barcode..

Is it possible there could be a valid s on the end of your bar code so that
rather than abcdefss you want abcdefs as a result?

If so, you can still use either of the suggested solutions except you would
need to test for the last two characters being "ss"

"GregB" wrote in message
...
On the boxes I have come in an extra "S" is inlcuded on in the barcode
when
compared to the barcode on the item itself.
I scan stuff in by the box and scan stuff out by the item

I am trying to set an onclose event on a form utilizing vba to trim of the
"s" if there is an "s"

the field is called barcode
I know to use an IFF statement but can not get it right..
What would the code look like?

Thanks!



  #5  
Old October 27th, 2008, 06:39 PM posted to microsoft.public.access
GregB
external usenet poster
 
Posts: 115
Default Triming a letter from barcode..

Thanks Guys, sorry for the late reply I was on vacation. Hopefully you still
will look at this.

I trired Allens and Ricks method but it would not work...
And the S is on the begining of the barcode. S#########

The code you produced me dosn't proivde any errors it just dosn't do
anything... Of course I tried putting in serial numbers with an S at the
end.... still nothing?

Whats going on?

THanks

"Allen Browne" wrote:

The Close event of the form is too late.
Use the AfterUpdate event procedure of the text box.

Something like this:

Private Sub barcode_AfterUpdate()
If Me.barcode Like "?*S" Then
Me.barcode = left(Me.barcode, len(Me.barcode) - 1)
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"GregB" wrote in message
...
On the boxes I have come in an extra "S" is inlcuded on in the barcode
when
compared to the barcode on the item itself.
I scan stuff in by the box and scan stuff out by the item

I am trying to set an onclose event on a form utilizing vba to trim of the
"s" if there is an "s"

the field is called barcode
I know to use an IFF statement but can not get it right..
What would the code look like?

Thanks!



  #6  
Old October 28th, 2008, 01:14 AM posted to microsoft.public.access
Allen Browne
external usenet poster
 
Posts: 11,706
Default Triming a letter from barcode..

Private Sub barcode_AfterUpdate()
If Me.barcode Like "S?*" Then
Me.barcode = mid(Me.barcode, 1)
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"GregB" wrote in message
...
Thanks Guys, sorry for the late reply I was on vacation. Hopefully you
still
will look at this.

I trired Allens and Ricks method but it would not work...
And the S is on the begining of the barcode. S#########

The code you produced me dosn't proivde any errors it just dosn't do
anything... Of course I tried putting in serial numbers with an S at the
end.... still nothing?

Whats going on?

THanks

"Allen Browne" wrote:

The Close event of the form is too late.
Use the AfterUpdate event procedure of the text box.

Something like this:

Private Sub barcode_AfterUpdate()
If Me.barcode Like "?*S" Then
Me.barcode = left(Me.barcode, len(Me.barcode) - 1)
End If
End Sub


"GregB" wrote in message
...
On the boxes I have come in an extra "S" is inlcuded on in the barcode
when
compared to the barcode on the item itself.
I scan stuff in by the box and scan stuff out by the item

I am trying to set an onclose event on a form utilizing vba to trim of
the
"s" if there is an "s"

the field is called barcode
I know to use an IFF statement but can not get it right..
What would the code look like?


  #7  
Old October 28th, 2008, 07:28 PM posted to microsoft.public.access
GregB
external usenet poster
 
Posts: 115
Default Triming a letter from barcode..

nothing happens Allens...???

"Allen Browne" wrote:

Private Sub barcode_AfterUpdate()
If Me.barcode Like "S?*" Then
Me.barcode = mid(Me.barcode, 1)
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"GregB" wrote in message
...
Thanks Guys, sorry for the late reply I was on vacation. Hopefully you
still
will look at this.

I trired Allens and Ricks method but it would not work...
And the S is on the begining of the barcode. S#########

The code you produced me dosn't proivde any errors it just dosn't do
anything... Of course I tried putting in serial numbers with an S at the
end.... still nothing?

Whats going on?

THanks

"Allen Browne" wrote:

The Close event of the form is too late.
Use the AfterUpdate event procedure of the text box.

Something like this:

Private Sub barcode_AfterUpdate()
If Me.barcode Like "?*S" Then
Me.barcode = left(Me.barcode, len(Me.barcode) - 1)
End If
End Sub


"GregB" wrote in message
...
On the boxes I have come in an extra "S" is inlcuded on in the barcode
when
compared to the barcode on the item itself.
I scan stuff in by the box and scan stuff out by the item

I am trying to set an onclose event on a form utilizing vba to trim of
the
"s" if there is an "s"

the field is called barcode
I know to use an IFF statement but can not get it right..
What would the code look like?



  #8  
Old October 28th, 2008, 09:02 PM posted to microsoft.public.access
Klatuu[_3_]
external usenet poster
 
Posts: 396
Default Triming a letter from barcode..

I think Allen intended:
If Me.barcode Like "S?*" Then
Me.barcode = mid(Me.barcode, 2)
End If
End Sub

2 instead of 1. 1 returns the entire string.

"GregB" wrote in message
...
nothing happens Allens...???

"Allen Browne" wrote:

Private Sub barcode_AfterUpdate()
If Me.barcode Like "S?*" Then
Me.barcode = mid(Me.barcode, 1)
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"GregB" wrote in message
...
Thanks Guys, sorry for the late reply I was on vacation. Hopefully you
still
will look at this.

I trired Allens and Ricks method but it would not work...
And the S is on the begining of the barcode. S#########

The code you produced me dosn't proivde any errors it just dosn't do
anything... Of course I tried putting in serial numbers with an S at
the
end.... still nothing?

Whats going on?

THanks

"Allen Browne" wrote:

The Close event of the form is too late.
Use the AfterUpdate event procedure of the text box.

Something like this:

Private Sub barcode_AfterUpdate()
If Me.barcode Like "?*S" Then
Me.barcode = left(Me.barcode, len(Me.barcode) - 1)
End If
End Sub


"GregB" wrote in message
...
On the boxes I have come in an extra "S" is inlcuded on in the
barcode
when
compared to the barcode on the item itself.
I scan stuff in by the box and scan stuff out by the item

I am trying to set an onclose event on a form utilizing vba to trim
of
the
"s" if there is an "s"

the field is called barcode
I know to use an IFF statement but can not get it right..
What would the code look like?





  #9  
Old October 29th, 2008, 01:31 AM posted to microsoft.public.access
Allen Browne
external usenet poster
 
Posts: 11,706
Default Triming a letter from barcode..

Thanks, Dave. Greg, that's right: you want from the 2nd char.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Klatuu" wrote in message
...
I think Allen intended:
If Me.barcode Like "S?*" Then
Me.barcode = mid(Me.barcode, 2)
End If
End Sub

2 instead of 1. 1 returns the entire string.

"GregB" wrote in message
...
nothing happens Allens...???

"Allen Browne" wrote:

Private Sub barcode_AfterUpdate()
If Me.barcode Like "S?*" Then
Me.barcode = mid(Me.barcode, 1)
End If
End Sub

"GregB" wrote in message
...
Thanks Guys, sorry for the late reply I was on vacation. Hopefully you
still
will look at this.

I trired Allens and Ricks method but it would not work...
And the S is on the begining of the barcode. S#########

The code you produced me dosn't proivde any errors it just dosn't do
anything... Of course I tried putting in serial numbers with an S at
the
end.... still nothing?

Whats going on?

THanks

"Allen Browne" wrote:

The Close event of the form is too late.
Use the AfterUpdate event procedure of the text box.

Something like this:

Private Sub barcode_AfterUpdate()
If Me.barcode Like "?*S" Then
Me.barcode = left(Me.barcode, len(Me.barcode) - 1)
End If
End Sub


"GregB" wrote in message
...
On the boxes I have come in an extra "S" is inlcuded on in the
barcode
when
compared to the barcode on the item itself.
I scan stuff in by the box and scan stuff out by the item

I am trying to set an onclose event on a form utilizing vba to trim
of
the
"s" if there is an "s"

the field is called barcode
I know to use an IFF statement but can not get it right..
What would the code look like?


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:29 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.