Results 1 to 8 of 8
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Reset Fields After Button Click


    Hi Every One

    Code:
    Private Sub Text3_Change()
    Command1.Enabled = True
    Command1.Caption = "Save Lecturer ID " & Text1.Value
    Text1.Value = ""
    Text2.Value = ""
    End Sub
    I Have a Save button in my program(used wizard to save the text's), when i enter a value into my last text box( text3) my button enables. then i click on save.
    Now what i want to do is to reset the text boxes after i hit save button. I tried above code but it changes clears the text boxes before i hit the Save button. Can you help me on this?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    If you are working with a button Click event, why are you showing a Change event?
    What are you trying to do in plain English?

  3. #3
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    For example when i type "Employee ID" in my 1st text box then only the second text box enables and when i enter a text into my second text box it enables the save button.

    And i did not code for button click event, i used the default function in access.

    How do i clear the textboxes after i hit the save button.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You don't need to explicitly save a record in Access. Access will save a record when you move to another record.

    Your post title is
    Reset Fields After Button Click
    ??

  5. #5
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Yeah i want to reset the fields after the button click. how to do it?

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Here is a sample code I found via Google

    Code:
     Private Sub resetbtn_Click()  ' replace resetbtn with your button's name
    
     Me.clientname = ""        'Me refers to the current form and the items following the dot are controls on the form
     Me.operatingstate = ""
     Me.product = ""
    Me.Refresh                     'refresh the form using the new vales (resetting) the controls on the form
    
    End Sub

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Are these bound or unbound controls?

    If controls are bound, then 'resetting' will delete data from record. Possibly what you should do is just move to a new record row.

    Refresh will do nothing to requery comboboxes.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    but it changes clears the text boxes before i hit the Save button.
    because the change event fires before you can ever get to the button click. The last post re bound fields is crucial - don't overlook it. Don't entirely agree that navigating to or making a different record the current one is always the way to go. Sometimes the user needs to save progress in order to generate related data, such as a document/invoice/record number without leaving the record on the active form, but navigation is often simple enough, as is closing the form, which will also save the current record.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Creat a Clear or Reset button
    By rebfein in forum Forms
    Replies: 8
    Last Post: 11-03-2017, 05:19 PM
  2. Countdown Timer w/ Reset on Button Click
    By ScubaSteve in forum Forms
    Replies: 1
    Last Post: 05-11-2017, 06:43 AM
  3. Reset button vba for a File Search
    By redekopp in forum Forms
    Replies: 10
    Last Post: 11-17-2015, 02:31 PM
  4. Asc/Desc/reset sort button code
    By mightyteegar in forum Programming
    Replies: 2
    Last Post: 10-30-2012, 04:24 PM
  5. Replies: 3
    Last Post: 06-18-2012, 07:14 AM

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