I think you will need to do this using a text field, because a numeric one will probably cause an error before trying to remove the ‘Q’.
I hope someone else provides a better solution, but meanwhile…
You could use an unbound text field and in the ‘AfterUpdate’ event remove the ‘Q’ and assign the resultant value to your quantity field (which should be hidden). Then, in some form event such as ‘Current’ you could copy the value from your hidden quantity field to your visible unbound text field, so users can see what is in your database field when using the form to read.
Assuming a text field ‘Text1’, the code would be something like this:
<pre>Private Sub Form_Current()
Text1 = quantity
End Sub
Private Sub Text1_AfterUpdate()
If Left(Text1, 1) = “Q” Then
quantity = Mid(Text1, 2)
Else
quantity = Text1
End If
End Sub</pre>
Other validations should be performed in order to ensure that Text1 doesn’t contain other non-numeric characters.
Hope this helps.
-CarlosDL
———–
Discuss This Question: 1  Reply