Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2010

    Unanswered: How Can I do This?

    Hi All,

    I have a form with an unbound text box that is not enabled.

    I'd like a button that you click (called Add) on that makes the textbox enabled.

    You enter your text, then click a button called "Save" that copies that text to a table, then disables the textbox again.


    Someone can suggest a way, that you add a new record, and it isnt committed until you click a "Save" button or similar.

    (Its important I have the "2" button funtionality, Add then Save)


  2. #2
    Join Date
    Jan 2010
    Ok, here's an example that might help you out:

    1. Create 2 text boxes. Name them: txtEmployeeFirstName and txtEmployeeLastName
    2. Create 2 Buttons. Name them: employee_add and employee_save
    3. Use the code below:

    Private Sub employee_add_Click()
        txtEmployeeFirstName.Enabled = True
        txtEmployeeLastName.Enabled = True
    End Sub
    Private Sub employee_save_Click()
        If IsNull(txtEmployeeFirstName) Then
            MsgBox "please enter a first name"
            Exit Sub
        End If
        If IsNull(txtEmployeeLastName) Then
            MsgBox "please enter a last name"
            Exit Sub
        End If
        With Me.Form.RecordsetClone
            !EMPFirstName = txtEmployeeFirstName
            !EMPLastName = txtEmployeeLastName
        End With
        txtEmployeeFirstName = ""
        txtEmployeeLastName = ""
        txtEmployeeFirstName.Enabled = False
        txtEmployeeLastName.Enabled = False
    End Sub
    You will need to create an unbound text box for every field for the table, in this example the fields are first name and last name, if you had more fields, then obviously you would create more text boxes and in the:

    With Me.Form.RecordsetClone
    ![FieldNameOfTable] = [TextBoxOnForm]


Posting Permissions

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