Results 1 to 2 of 2
  1. #1
    NSKD is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    3

    How to input text via dedicated command button

    Hi Guys,



    I have 2 text boxes and 1 push button for each text box for input to table. When I click on 'SaveInput1' only Input1 is save onto the Table and when 'SaveInput2' is click only Input2 is save. I want each command button to save each input separately.

    I know ACCESS have a SAVE RECORD function, but I do not want to use this because it will save the entire record all at once. Can someone please help me on this.

    -----------------

    TextBox1 = Input1
    TextBox2 = Input2

    Commandbutton1 = SaveInput1
    Commandbutton2 = SaveInput2

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I have a some questions here:

    1) Is your form bound to a table.
    2) are the text boxes in question unbound or bound to a field (has a control Source).
    3) In Inputs that you want to save are they default values or you a user will enter data in them.

    let us take an example:
    I have a table with the following fields:

    ID(Autonumber PK)
    Input1(Text)
    Input2(Text)

    I have a form bound to my Table with two text boxes bound to Input1 and input2.

    in this case as you type in the values in the text box the data is saved in the table.

    But suppose your table is like this

    ID
    Input

    Now I have a form bound to my table I have two unbound Text Boxes Text1 and Text2 and Two command Buttons Command1 and Command2. There are the bound Text Box Controls ID and Input.

    When Data is entered in the unbound text Boxes they are not saved in the table.

    Now putting this code in the on click event of the buttons will do the needful:

    CommandButton1

    Me.Input=Me.text1

    CommandButton

    Me.Input=Me.Text2


    But I have another Suggestion:

    if data entry is your only motive:

    you can have a unbound form with two text boxes Text1 and Text2. And CommandButtons 1 and 2


    CommandButton1
    Dim rst DAO.Recordset
    rst=currentdb.openrecordset("TableName")
    rst.AddNew
    rst!Input=Me.Text1
    rst.Update
    rst.close
    Set rst=Nothing

    CommandButton

    Dim rst DAO.Recordset
    rst=currentdb.openrecordset("TableName")
    rst.AddNew
    rst!Input=Me.Text2
    rst.Update
    rst.close
    Set rst=Nothing


    I may have completely misunderstood you requirement. Please let me know if you have any queries

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Command button to input data in a table
    By wilsgaard in forum Forms
    Replies: 1
    Last Post: 08-07-2011, 07:59 PM
  2. Replies: 11
    Last Post: 06-02-2011, 10:21 AM
  3. Replies: 15
    Last Post: 04-01-2011, 11:41 AM
  4. Replies: 1
    Last Post: 09-13-2010, 01:57 PM
  5. Replies: 1
    Last Post: 07-27-2010, 02:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums