On Click Event

dogman01

Registered User.
Local time
Today, 17:53
Joined
Dec 3, 2008
Messages
47
I have a button on a form and I want it to insert a text value into a field when pushed. Lets say I want it to insert the work "Leg" into the "body_part" field. How would I write the event code. I am not much on code but I do know how to copy and paste. Thanks
 
Place a button on your form and name it cmdInsertLeg. Then place this code behind it:
Code:
Private Sub cmdInsertLeg_Click()
If IsNull(Me.Body_Part) Then
   Me.Body_Part = "Leg"
  Else
   Me.Body_Part = Me.Body_Part & "; " & "Leg"
  End If
End Sub

This code allows you to just enter the one body part, or if you need to insert more than one, it'll place a semi-colon between each part. Placing more than one piece of data in a single textbox is sometimes necessary, but you should think carefully before doing so. Manipulating a field with more than one piece of data can be complicated.

If you need help placing the code, here's an excellent tutorial:

http://www.btabdevelopment.com/main/QuickTutorials/Wheretoputcodeforevents/tabid/56/Default.aspx
 

Users who are viewing this thread

Back
Top Bottom