+ Reply to Thread
Results 1 to 2 of 2

Any way to clear all the values in a form with a single command?

  1. #1
    Registered User
    Join Date
    09-20-2016
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    7

    Any way to clear all the values in a form with a single command?

    Hi,

    I created a form with a save button which copy the values of the various field in a sheet in Excel. Isuue is that when I hit save the fields in the form remain populated so if I hit it again the same record get saved.

    Is there a simple way to clear all the field? mind that there are some textbox, some datechangers and some combobox.

    rivate Sub CmdSave_Click()



    Sheet1.Activate

    Range("B2").End(xlDown).Offset(1, -1).Select


    ActiveCell.Offset(0, 1).Value = dtpCaseReceivedDate.Value
    ActiveCell.Offset(0, 3).Value = dtpCXReceivedDate.Value
    ActiveCell.Offset(0, 5).Value = txtCaseNumber.Value
    ActiveCell.Offset(0, 6).Value = cboAgentName.Value
    ActiveCell.Offset(0, 7).Value = cboLanguage.Value
    ActiveCell.Offset(0, 8).Value = cboCXQ1Score.Value
    ActiveCell.Offset(0, 9).Value = cboCXQ2Score.Value
    ActiveCell.Offset(0, 10).Value = cboCXQ3Score.Value
    ActiveCell.Offset(0, 11).Value = cboCXQ4Score.Value
    ActiveCell.Offset(0, 12).Value = cboCXQ5Score.Value
    ActiveCell.Offset(0, 13).Value = txtCXQ6.Value
    ActiveCell.Offset(0, 14).Value = txtCXQ10.Value
    ActiveCell.Offset(0, 15).Value = CboCOntrollable.Value
    ActiveCell.Offset(0, 16).Value = cboCxToBeSent.Value
    ActiveCell.Offset(0, 17).Value = txtConsumerIssue.Value
    ActiveCell.Offset(0, 18).Value = txtResolution.Value
    ActiveCell.Offset(0, 19).Value = txtAgentFailed.Value
    ActiveCell.Offset(0, 20).Value = cboVoicy.Value
    ActiveCell.Offset(0, 21).Value = cboCXAwarness.Value
    ActiveCell.Offset(0, 22).Value = cboCallBackNeeded.Value
    ActiveCell.Offset(0, 23).Value = txtCommentsActions.Value

    End Sub


    Thanks
    Filippo
    Last edited by Filippo_Santarelli; 09-20-2016 at 11:58 AM. Reason: Solved

  2. #2
    Registered User
    Join Date
    09-20-2016
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    7

    Re: Any way to clear all the values in a form with a single command?

    I added this code I built using other code found online

    For Each ctl In Me.Controls
    Select Case TypeName(ctl)
    Case "TextBox"
    ctl.Value = ""
    Case "CheckBox", "ToggleButton" ' Removed OptionButton
    ctl.Value = False
    Case "OptionGroup" ' Add OptionGroup
    ctl = Null
    Case "OptionButton" ' Add OptionButton
    If TypeName(ctl.Parent) <> "OptionGroup" Then ctl.Value = False
    Case "ComboBox", "ListBox"
    ctl.ListIndex = -1
    End Select
    Next ctl

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need a command button to both Clear and Insert values in specific fields.
    By silverpetals in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2016, 04:00 PM
  2. Create form to handle multiple values for single record
    By dougdrex in forum Access Tables & Databases
    Replies: 1
    Last Post: 05-13-2014, 04:19 PM
  3. Convert a single column with variables and values across many rows into Table form!
    By paul2014 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-27-2014, 09:18 PM
  4. Print sheet with changed cell values in single command
    By matvmat in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-24-2013, 03:07 AM
  5. [SOLVED] User Form to input values only after command button executed and refresh workbook
    By concatch in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2013, 09:41 AM
  6. [SOLVED] can someone help modify the clear command to only clear columns from A-G?
    By psunursingguy21 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-30-2013, 03:52 PM
  7. Add a clear values code to command button
    By titantough in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-14-2011, 01:15 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1