manipulate data before saving to table

D

Daniel M

Ok this partically gets me what i need. now i face a new issues.

The control i am entering in the data too has a control source of a table
column. this table column is a number field. Because of this it will not let
me put in the '-' even though the code takes it out. is there a way to do
this?

alternately if i change the field to text instead of number i have an issue.
some serial numbers are 02-001234 and some are 02-203213. if it just strip
off the "02-" then 001234 is entered into the table, but i only want 1234. if
this is a number the leading 00 is stripped off.

So here is what i need.
entered/scanned data data put in table
02-001234 1234
02-205678 205789
1235 1235
 
U

UpRider

Daniel, try this in the immediate window and see if it does what you want:

?val(replace("02-001234","02-",""))

UpRider
 
D

Daniel M

What do you mean by immediate window? Thanks.

UpRider said:
Daniel, try this in the immediate window and see if it does what you want:

?val(replace("02-001234","02-",""))

UpRider
 
U

UpRider

Daniel, if a text string contains only the digits 0 thru 9, the VAL function
will convert the text string to numeric, stripping off any leading zeros.
We don't know how you used BruceM's code examples, so specific instrucions
are impossible, but you could try something like this:
Me.ShortField = Val(Right(Me.LongField,Len(Me.LongField) -
InStr(Me.LongField,"-"))

Above just wraps the existing expression with Val()

UpRider
 

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