Ignoring commas when users enter data

shabbaranks

Registered User.
Local time
Today, 09:08
Joined
Oct 17, 2011
Messages
300
Hi,

Am I correct in thinking the terminology is called parsing? If so.. Then what I am trying to do is when users enter a description into a field they occasionally add commas etc. How do I allow them to enter them? Or do I need to have some method of removing them on submittion?

Thanks in advance
 
You could use the Replace() function in the field's After Update event.
Something like;
Code:
Me.YourTextField = Replace(Me.YourTextField, ",", "")
Should do the trick.
 
Thanks John, I think the fact I am calling the description then trying to change the value is causing me problems as per my code below:

Code:
sHourType = Me.Hour.Value
sCostCode = Me.CostCode
sActivity = Me.Activity.Column(0)
sProject = Me.Project.Column(2)
sHours = Nz(Me.Hour, 0)
sDescript = Nz(Me.Description, " ")

then

Code:
If sHourType > 0 Then
sHourType = "CD"
Else
sHourType = "CC"
End If
Me.Description = Replace(Me.Description, "'", "")

How would I combine the Me.Description? Or would I do it another way?

Thanks
 
You could also use the Form's KeyPress event:
Code:
    If KeyAscii = 44 Then
        KeyAscii = 0
    End If
If you're going to use this method, remember to set the KeyPreview property of the form to Yes.
 
You could do any replacements in the BeforeUpdate event of the Description field.

Code:
Public Sub Description_BeforeUpdate()
Me.Description = Replace(Me.Description, "'" , "")
Me.Description = Replace(Me.Description, "," , "")
...
End Sub

The rogue characters would be stripped out before the field was saved.
 
shabbaranks

You have a couple of ticking time-bombs in your db.

You are using reserved words for field names - Hour, Project and Description.

This may explain why you are having trouble with your code.
 

Users who are viewing this thread

Back
Top Bottom