I just split a database that has been in use for several years. Other groups at my site are looking at using a copy of the database and I wanted an easy way to distribute modifications. I realized that several of modules caused errors because of the specified type in the openrecordset statement and fixed that. It appears that everything is working correctly except one module. It is used to programatically add data to one of the tables in the backend database (see code below). However, once it executes it appears to leave something open because I can't run any other code or even close the form from which the module below is called. I thought it might be because I hadn't set the type of database and recordsets. But changing the code to Dim dbs As DAO.Database etc. didn't help. I also added the lines to close the recordsets and the database and set their values to nothing without solving the problem. Any help or suggestions would be appreciated. I am having to open another database before the hung database will open again.
Dim dbs As DAO.Database
Dim frm As Form
Dim rst As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim X As Integer
Dim Project As Integer
Dim StartDate As Date
Dim EndDate As Date
Dim LastDate As Date
Dim NextDate As Date
Dim Unit As String
Dim Freq As Integer
Dim lngrecordnum As Integer
On Error GoTo cmdAddDatesError
'Pick up info from current Projects in form
Set dbs = CurrentDb
Project = Me![ProjectID]
StartDate = Nz(Me![StartDate], Now())
EndDate = Nz(Me![EndDate], DateAdd("YYYY", 1, Now()))
Freq = Me![Frequency]
Unit = Me![FrequencyUnits]
LastDate = StartDate
NextDate = DateAdd(Unit, Freq, LastDate)
Set rst = dbs.OpenRecordset("tblDueDates")
'Create Due Date from Initial Start Date
With rst
.AddNew
!ProjectID = Project
!DueDate = StartDate
On Error Resume Next
.Update
End With
'Create Due Dates until End Date based on repeat frequency
Do Until NextDate > EndDate
With rst
.AddNew
!ProjectID = Project
!DueDate = DateAdd(Unit, Freq, LastDate)
LastDate = !DueDate
NextDate = DateAdd(Unit, Freq, LastDate)
On Error Resume Next
.Update
End With
Loop
cmdAddDatesExit:
Me.Refresh
rst.Close
rst2.Close
dbs.Close
Set rst2 = Nothing
Set rst = Nothing
Set dbs = Nothing
Exit Sub
cmdAddDatesError:
MsgBox Err.Description
Resume cmdAddDatesExit



