Results 1 to 9 of 9
  1. #1
    rebfein's Avatar
    rebfein is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2015
    Location
    So Cal
    Posts
    114

    Creat a Clear or Reset button

    After a lot of trial & error, I finally got this search form to work.
    Click image for larger version. 

Name:	Mod Search Form.png 
Views:	18 
Size:	10.1 KB 
ID:	31047

    Enter the model number, press the search button and the resulting information pops un in a query form
    Click image for larger version. 

Name:	Result.png 
Views:	18 
Size:	16.3 KB 
ID:	31048

    But now, we need a button that will clear the information from the form screen.

    Any suggestions?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    do you mean :
    erase the data?
    or
    or close the datasheet? (theres a close button on the app for this)

  3. #3
    rebfein's Avatar
    rebfein is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2015
    Location
    So Cal
    Posts
    114
    I mean "we need a button that will CLEAR the information from the form screen." without changing the data in the table. Allowing the user to enter in another model number. Currently, the datasheet has to close in order for new data to appear in it the next time the form is used.

    Thank you

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,411
    Currently, the datasheet has to close in order for new data to appear in it the next time the form is used.
    What new data? Does the 'Run Query' button do a data insert?

    "we need a button that will CLEAR the information from the form screen."
    When we ask for clarification, merely repeating yourself does not clarify your need. Do you mean that you want to put another button on the Mod Search Form that will blank out the "KGS Model:" textbox?
    That shouldn't be necessary. Code can be added to the 'Run Query' button that will do that after the query is fired off.

    OR do you mean that with the situation shown in your post, you want to enter a new KGS Model, press the Run Query button and the existing query display disappears and a new one pops up with the new KGS Model information?
    OR something else?
    Are you using macros or VBA?

  5. #5
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    So many ways to skin a cat as the saying goes. Same here.
    Why not enter a new value, click the existing button and requery the datasheet - assuming that's what you meant by a "query form" in one instance, and "datasheet" in another?
    Or change the textbox to a combo and use its AfterUpdate event to requery the datasheet since the entered value must be in a table anyway.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I would use a combo box because you wouldn't have to enter an exact match before you saw the model you want.
    Whether you use a combo box, list box or a text box, it would have to be unbound. The last line of the subroutine would be
    Code:
    Me.ControlName = Null
    (change ControlName to the name of your control)

  7. #7
    rebfein's Avatar
    rebfein is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2015
    Location
    So Cal
    Posts
    114
    I apologize for the confusion.

    This is a search form linked to a query with an unbound text box.

    After a model number is entered and the Run Query button is clicked on, the results appear in a Query datasheet.

    Currently, in order to run another model number, the user must close the data sheet, then clear out or write over the number in the text box.

    I would like to add a 'Clear' button that will clear/erase the previously entered number from the text box.

    I used the wizard to create a button (called 'Clear'), with the Category set to Record Operations and the Actions set to Undo Record. However, this does not apparently work.

    Any suggestions...

  8. #8
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,411
    davegri_test1.zip
    This should get you there.

  9. #9
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Nice solution, davegri. A one button form with a test for the textbox not being empty would be another way (not necessarily better).
    Code:
    Private Sub cmb_search_Click()
    
    If txtModelSearch <> "" Or Not IsNull(txtModelSearch) Then
       DoCmd.Close acQuery, "qModelSearch"
    End If
    
    If DCount("*", "qModelSearch") > 0 Then
       DoCmd.OpenQuery "qModelSearch", , acReadOnly
    Else
       MsgBox "This search has no records, try again"
    End If
    
    End Sub

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

Similar Threads

  1. Countdown Timer w/ Reset on Button Click
    By ScubaSteve in forum Forms
    Replies: 1
    Last Post: 05-11-2017, 06:43 AM
  2. Reset button vba for a File Search
    By redekopp in forum Forms
    Replies: 10
    Last Post: 11-17-2015, 02:31 PM
  3. Replies: 2
    Last Post: 03-12-2014, 01:31 AM
  4. Asc/Desc/reset sort button code
    By mightyteegar in forum Programming
    Replies: 2
    Last Post: 10-30-2012, 04:24 PM
  5. Replies: 5
    Last Post: 09-09-2012, 04:14 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