Access 2010: How do I clear the fields in a form when I hit a close button

We have a database built in MS Access 2007.  However, we have recently migrated all of our users to MS Office 2010.  When using the database the user inputs data into a form that automatically pops up when opening the database.  When done, the user hits a "Close" button which then triggers a save action, an action to clear the form fields, then closes the form.  This works flawlessly when opening the database in MS Access 2007, but errors out when opening it in Access 2010 with ("Can't go to the specified record").  The code for clearing the form is below.

Anyone have any ideas?

Thanks in advance!
Private Sub CMD_QUIT_Click()
On Error GoTo Err_CMD_QUIT_Click

    DoCmd.OpenQuery "Q_APPEND"
    
    Call DELETER
    
    
    DoCmd.Close

Exit_CMD_QUIT_Click:
    Exit Sub

Err_CMD_QUIT_Click:
    MsgBox Err.Description
    Resume Exit_CMD_QUIT_Click
    
End Sub

Private Sub DELETER()

    Dim stemp As String
    
    DoCmd.GoToRecord , , acLast
        stemp = SSN
    
    DoCmd.GoToRecord , , acFirst
    
        Match = ""
        Total = ""
        Gross = ""
        Withheld = ""
        Date = ""

    Do Until SSN = stemp
    
        DoCmd.GoToRecord , , acNext

        Match = ""
        Total = ""
        Gross = ""
        Withheld = ""
        Date = ""
        
        
        
    Loop
    
    
End Sub

Open in new window

Jayhawk05Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Just curious, why do you need to clear these fields when the Form closes, since that will automatically clear the fields?

In the meantime, quick and dirty:

On Error Resume Next
DoCmd.GoToRecord , , acNext
Err.Clear

see if there are any ill effects doing this ...

mx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jayhawk05Author Commented:
My understanding of the situation is that one of the functions of the close button is that it also saves the data submitted to another table prior to closing the form.  Then, it's supposed to clear the data entered for the user the next time he opens it.  (You'll have to forgive me if I'm not answering your question completely clearly; I'm new and just had this thrown in my lap.)

Your bit of code appears to have done the trick!  Thank you!
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
" Then, it's supposed to clear the data entered for the user the next time he opens it."
But that would/will happen automatically when Form is closed.  'Data' in those controls will be gone when form reopens, assuming you open to a New Record OR this form is Unbound ...?

"My understanding of the situation is that one of the functions of the close button is that it also saves the data submitted to another table prior to closing the form."
Well, that may be ... depending on what "Q_APPEND" actually does ..?

mx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.