manipulate data before saving to table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Daniel, try this in the immediate window and see if it does what you want:

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

UpRider
 
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
 
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
 
Back
Top