Stopping user from changing text HELP (1 Viewer)

crich21

Registered User.
Local time
Today, 07:09
Joined
Jan 10, 2003
Messages
86
I have a textbox called "comments". In this field I have text already entered. I want to allow users to add to the text I already have without erasing my text.
Ex. if the field contained "48 inch side door" I want to evaluate the string. If thr is no hyphen then add one and move to the position after the hyphen.

So "48 inch side door" keydown should add a hyphen and move to that position
"48 inch side door -" then everytime thr is a keydown I would have to evaluate if there is a hyphen then let them type unless the cursor is before the hyphen
 

DCrake

Remembered
Local time
Today, 12:09
Joined
Jun 8, 2005
Messages
8,632
What youwant is a seperate text box that is used to concatenate new text to existing text

Me.ExistingText = Me.ExistingText & " - " & Me.NewText
 

crich21

Registered User.
Local time
Today, 07:09
Joined
Jan 10, 2003
Messages
86
I forgot to mention the subform is in datasheet view!

I would like a solution that doesn't require adding another field
I have PartsID field and PartsComments field
I added the ability to select parts that we build in house.
When a part we build in house is selected the PartsID is "12345" and a description is added to PartsComments.
I usually let users change any comments on bought parts but on parts built in house I use the Partscomments as a description.
So I would rather be able to just add a simple text string to the end of the Partscomments on parts built in house rather than adding another field

Is this possible?
 
Last edited:

crich21

Registered User.
Local time
Today, 07:09
Joined
Jan 10, 2003
Messages
86
Code:
Private Sub Comments_Enter()
    Me!Comments.SelStart = InStr(1, Me.Comments.Text, "-")
End Sub

Private Sub Comments_KeyDown(KeyCode As Integer, Shift As Integer)
lngInHouseParts = 927259127

    Select Case KeyCode
    Case vbKeyF5 'QUOTE ONLY'
        Exit Sub
    Case vbKeyF6 'REMOVE QUOTE ONLY'
        Exit Sub
    Case vbKeyUp
        Exit Sub
    Case vbKeyDown
        Exit Sub
    Case Else
        If Me.WorkOrderInstructionID = lngInHouseParts Then
            If InStr(1, Me.Comments.Text, "-") > 0 Then
                If Me.Comments.SelStart < InStr(1, Me.Comments.Text, "-") Then
                    msgbox "You cannot change description" & _
                   Chr(13) & "of parts built in house.", vbOKOnly
                    DoCmd.CancelEvent
                End If
            Else
                    Me.Comments.Text = Trim(Me.Comments.Text) & " - "
            End If
        End If
    End Select
End Sub
this appears to be working but its slow. Is there a faster method?
 
Last edited:

Users who are viewing this thread

Top Bottom