Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2014

    Unanswered: Create a button on a form that puts a set value into a textbox

    How can I nmake a button that puts a value into a textbox on the same form? I want to make it so that the user cant edit the text in the textbox, so that the only options are the buttons that I create.

  2. #2
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    In Form Design View
    1. Right-Click the Textbox in question
    2. Click on Properties
    3. Click on the Data Tab
    4. Set the Locked Property to Yes
    5. Create your Command Button

    Now use code like this with the button
    Private Sub cmdSetValue_Click()
     Me.TextboxName = "Whatever"
    End Sub

    If the value is Numeric you'd use

    Me.TextboxName = YourNumberValue

    If you'll ever need the users to simply make the Control blank, again (i.e. they make a mistake and do not know what the value should be) use

    Me.TextboxName = Null

    Having said that, a better idea might be to use a Combobox instead of multiple Buttons to populate the Field. It can be Bound to the Underlying Field (with the Textbox deleted) or simply used to assign the Value to the Textbox.

    Linq ;0)>
    Last edited by Missinglinq; 06-18-14 at 13:48.
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Apr 2014
    Provided Answers: 35
    Set the text box property LOCKED = true (data tab)
    Then fill a text box on the button click event...

    txtBox = Dlookup("[Name]",tblClients,"[Id]=" & txtID

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts