Help with changing alpha string to Numeric

N

NNlogistics

Please forgive me if this is a duplicate question.

I am trying to Change an alpha string to a number. It works in one case and
not the other. I am using the msgbox for trouble shooting. The
txtPOtoRMATransision and txtPOtoRMATransision2 were added during the
troubleshooting process. They are unbound txtboxes. The control source for
Me.txtRMANumber is numeric - long integer. It works for PM0000193-2 and not
for PM0000193-20. Hope this is clear.

Happy New Year to all!

' Change PO number to RMA # if Customer Number is 1


' Change PO number to RMA # if Customer Number is 1
' if not 1 then go to fldseqnumber and add 1 for the RMA Number

If txtCustomerID = "1" Then 'using PM0000193-2 and PM0000193-20 as examples
Me.txtPOtoRMATransision = Left(Me.txtPONumber, 9) & Mid(Me.txtPONumber, 11,
2) 'gives PM00001932 and PM000019320 respectively
MsgBox (Me.txtPOtoRMATransision) 'gives PM00001932 and PM000019320
respectively
Me.txtPOtoRMATransision2 = "8" & Mid(Me.txtPOtoRMATransision, 3)
MsgBox (Me.txtPOtoRMATransision2) 'gives 800001932 and 8000019320 respectively

Me.txtRMANumber = Me.txtPOtoRMATransision2 ' *****here I am getting run time
error "2147352567 the value for this field ins't valid
Me.txtSalesOrderNumber.SetFocus 'Then enter Sales Order Number
 
J

Jeff Boyce

How are you "trying to change"...? What function or procedure are you
using?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
D

Douglas J. Steele

Try

Me.txtRMANumber = CLng(Me.txtPOtoRMATransision2)

or, safer,

If IsNumeric(Me.txtPOtoRMATransision2)
Me.txtRMANumber = CLng(Me.txtPOtoRMATransision2)
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top