Results 1 to 10 of 10
  1. #1
    JimO is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    126

    Button to reset field value to ""

    Looking to have a button on a continuous form that will reset the value of a field [Progress] to a blank value.



    Code:
    Private Sub Command20_Click()
        Me.Progress.Value = ""
    End Sub
    I tried this code but I get nothing.

    Jim O

  2. #2
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    I think more information is needed. Is the button part of the continuous record, how ever many records are displayed there is a button for each? If so then the answer would be identical to my reply to your other post. Update SQL with reference to the line ID setting progress="".

  3. #3
    JimO is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    126
    Thanks for the response,

    It is a continuous form and I want to reset all records in the field [Progress] to "". There is only a total of 30 rows and I use this field to keep track of my progress. It is a temporary repeatable process, so when a cycle is complete I can reset the form as a whole rather than delete all 30 individually.

    Jim O

  4. #4
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    ok, if I remember correctly leave out the where condition and just try an update SQL. Something like

    currentdb.execute("update tablename SET progress=null")

  5. #5
    JimO is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    126
    Here is my latest try. When I click the button nothing happens.

    Code:
    Private Sub Reset_Click()
        CurrentDb.Execute ("update SportsMLBFrm SET progress=null")
    End Sub
    Jim O

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    Is SportsMLBFrm a form? The update query can only updata a table.

    Code:
    CurrentDB.Execute "Update MyTable Set Progress = " & null
    If you want a zero length string, use vbNullString instead of null in the query.
    Last edited by davegri; 06-26-2016 at 02:15 PM. Reason: clarity

  7. #7
    JimO is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    126
    It is a form. I am tracking baseball results and have a form of teams with wins and losses. As a game is complete I enter the results and mark the game as complete (the [Progress] field). The next day I use the same form (table) to record the days results, I am just looking for a way to clear the [Progress] field with a button to clear all records in the progress column rather than go through and delete each one separately.
    Here is what I have so far that does not work.

    Code:
    Private Sub Reset_Click()
        CurrentDb.Execute "Update SportsMLBFrm Set Progress = " & Null
    End Sub
    Jim O

  8. #8
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    What's the name of the table where progress is located? Put that table in the update not the form. Then after the update add a requery, me.sportsmlbfrm.requery, so that it updates your form.

  9. #9
    JimO is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    126
    Entered this code to the field [WinLoss] on the form I am working with and not getting any results.

    Code:
    Private Sub Win__AfterUpdate()
        CurrentDb.Execute ("update MLBTbl set Date" & Date & "where MLBTblID=" & Me.ID.Value)
        Me.sportsmlbfrm.Requery
    End Sub
    Jim O

  10. #10
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    Code:
     CurrentDb.Execute ("update MLBTbl set Date" & Date & "where MLBTblID=" & Me.ID.Value)
    There's a couple of problems here. The field Date in your MLBtbl is using an Access reserved word, Date. In your table, change the fieldname to something else, like WLDate.
    Second, your sql produces incorrect syntax. It's missing an equal sign (=) and it needs a couple of spaces to avoid jamming things together in a way that the SQL interpreter cannot process.

    Code:
    CurrentDb.Execute ("update MLBTbl set Date = " & Date & " where MLBTblID= " & Me.ID.Value)
    Last edited by davegri; 06-27-2016 at 10:56 AM. Reason: clarity

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

Similar Threads

  1. Replies: 6
    Last Post: 11-21-2015, 09:52 AM
  2. Replies: 8
    Last Post: 10-24-2012, 12:47 PM
  3. Replies: 11
    Last Post: 03-29-2012, 02:32 PM
  4. Replies: 0
    Last Post: 01-11-2012, 12:34 PM
  5. Create "reset filter" button
    By vanlanjl in forum Access
    Replies: 0
    Last Post: 03-03-2009, 07:36 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