Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't quit Access Application

Status
Not open for further replies.

KMKelly

Programmer
Jan 23, 2002
35
0
0
US
I have a patient database that will not close. It only happens if a new daily record is added. I can use the exit option if I look at data or a report, but when I add a new daily record it copies data from a previous days record into the new record using a recordset clone. After that, when you click on the close button (Application.Quit), only the main form closes leaving the Access application window open and unclosable. Neither the control box exit button or the File menu Exit item will close the application window. It needs to be closed in task manager.

I got the recordset clone code online somewhere (I know I should have commented that). Here it is:

Code:
Dim RS As Recordset
Dim c As Control
Dim FillFields As String
Dim FillAllFields As Integer

On Error Resume Next

'Exit if not on the new record.

If Not F.NewRecord Then
     Exit Function
Else
'Go to the last reocrd of the form recordset (to autofill form)
     Set RS = F.RecordsetClone
     RS.MoveLast
     'Exit if no records
     If Err <> 0 Then Exit Function

     'Going to fill all fields
     FillAllFields = -1

     F.Painting = False

     'Visit each field on the form
     For Each c In F
     'fill each field
     If FillAllFields Then
         c = RS(c.ControlSource)
     End If
     Next

     'Need to delete the info in certain fields
     F!PICU_Units = Null
     'List of fields to exclude, edited out


     F.Painting = True
End If

RS.Close
Set c = Nothing

The only reference I could find to this problem was in the Knowledge Base:
I figured it was a recordset that was still open so I used Find Next and explicitly closed every recordset but that didn't resolve the problem.

I get no error messages at the time of close, just this blank unclosable application window. Is there anyway to list any object that is still open?

Does anyone have any ideas? Thanks.

Kris
 
I found another thread this discusses this without resolution: thread705-867742 I am linking to tables SQL Server if that makes any difference. Not sure there is any resolution to the recordsetclone method of doing this.

 
If a tree falls in a forest...

Answering my own question in case anyone happens upon it with a similar problem.

There was really no error handling beyond Move Next in my original code, and there were errors occurring. I tried setting up to find out what and where. The 1st problem was that it hit every control including buttons etc, so I used a line to limit the replacement to check boxes, text boxes, and combo boxes.

I replaced a section of the code above with:

Code:
If (TypeOf c Is TextBox Or TypeOf c Is ComboBox Or TypeOf c Is CheckBox) And c.Tag <> 1 Then
    c = RS(c.ControlSource)
End If
Next

The Tag property was set for every field that was unbound and filled by some other means or fields that I didn't want carried over. I was able to get to a point where there were no errors and the application closed fine.

Despite the Move Next which would presumably move forward to the portion of the code that closed the recordsets etc, the errors were preventing the application from closing even as they did allow it to fill in all the other fields with data. So it seemed fine until it hung up at the end.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top