Adding a - to the end of a string.

Talismanic

Registered User.
Local time
Today, 16:39
Joined
May 25, 2000
Messages
377
Is it possible to add a - to the end of a entered record in a control so that if the user tyes K756 the record would be instantly changed to K756- ?

I know that I could concantenate it with a & but I have a before update that checks for valid numbers that is causing me problems when I try it. Here is the code:

Private Sub JobNumber_BeforeUpdate(Cancel As Integer)

Dim strMsg As String, strTitle As String
Dim intStyle As Integer
Dim Answer As Variant

If DCount("[jobname]", "JobNumbers", "[JobNumber]= '" _
& Me!JobNumber & "'") = 0 Then
strMsg = "Please try a different number"
strTitle = "Invalid Job Number"
intStyle = vbOKCancel + vbInformation
Answer = MsgBox(strMsg, intStyle, strTitle)
If Answer = vbCancel Then Exit Sub
Cancel = True
End If

JobName = DLookup("[jobname]", "jobnumbers", "[jobnumber]= '" _
& Me!JobNumber & "'")

End Sub



[This message has been edited by Talismanic (edited 11-30-2000).]
 
Hi Talismanic

I would try to use the "&" as you mentioned (as long your data type is text). However before checking I would check for the existence of "-".

dim strJobNumber as string
Something like this:
if right(me!jobNumber,1) = "-" then
strJobNumber = left(me!JobNumber, _
len(me!jobNumber-1)
else
strJobNumber = me!jobNumber
end if

and then use strJobNumber for data validation.

Alternatively, you could use the imput mask (if "-" is only for display purposes).

Alternatively, it should be posible to check the values of the job numer (val(me!jobNumber)) instead of string values.

Hope that some of it will work for you
 
Hi Talismanic

I would try to use the "&" as you mentioned (as long your data type is text). However before checking I would check for the existence of "-".

dim strJobNumber as string
Something like this:
if right(me!jobNumber,1) = "-" then
strJobNumber = left(me!JobNumber, _
len(me!jobNumber-1)
else
strJobNumber = me!jobNumber
end if

and then use strJobNumber for data validation.

Alternatively, you could use the imput mask (if "-" is only for display purposes).

Alternatively, it should be posible to check the values of the job numer (val(me!jobNumber)) instead of string values.

Hope that some of it will work for you
 

Users who are viewing this thread

Back
Top Bottom