tickbox add item to a form field

antonyx

Arsenal Supporter
Local time
Today, 19:24
Joined
Jan 7, 2005
Messages
556
hi, i have a memo field, and on my form the control for that field is called

'pickup'

what i want on my form is a tick box button..

when the user clicks that button..

the words (O/S) appears inside the pickup control..


eg.

If I enter an address in the pickup field.. like so...

LHR - Terminal 1

then when the user clicks the box.. i would need the field to update as

LHR - Terminal 1 (O/S)

so really it would have to add a space and then the (O/S)

how can i do this?
 
On the click event of the tick box use an event proceedure that basically does this:
Me.MyMemoField = Me.MyMemoField & " O/S"

Of course what are going to do about them clicking it more than once?
 
ermmm... is there anything we can do??

well basically they will have to manually delete it if they click it twice, i know we are supposed to create full proof systems.. but u know...

it should be alrite.
 
I'm sure if you look into it (im only a novice at access) there will be code to deactivate the tickbox control. So Once clicked it wont work again?

Or you will need to check the field to see if it already has (O/S) at the end before applying it

Someone with more knowledge may be able to put the code in
 
Actually why would you use a tick box instead of a button? Are you storing the value of the tick box (I assume a tick box is a check box). It would be easy enough to use IF RIGHT(RTRIM(Me.MyMemoField),3) = "O/S" THEN EXIT SUB to stop it granted there is nothing past the O/S other than spaces.
 
I would have though this was fairly simple. I would use the after update event of the tick box to change what is in the pickup text box as so:

Code:
Private Sub CheckBox_AfterUpdate()

If Me.CheckBox = True Then
    If Right(RTrim(Me.pickup), 5) <> "(O/S)" Then
        Me.pickup = Me.pickup & " (O/S)"
    End If
ElseIf Me.CheckBox = False Then
    If Right(RTrim(Me.pickup), 5) = "(O/S)" Then
       Me.pickup = Left(Me.pickup, Len(Me.pickup) - 6) '6 digits to allow for the space
    End If
End If

End Sub

You could also have similar code in the On current event of the form to trap anything that has been missed by the above code.

HTH
 

Users who are viewing this thread

Back
Top Bottom