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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

External accdb won't unlock after using local querydef

Status
Not open for further replies.

thogan5

Programmer
May 17, 2010
5
0
0
US
I have an external accdb to hold work data and the results of that work. I then open a form that has a subform, whose Source Object is my querydef. When the form opens, the external accdb gets locked with a laccdb file. No prob. But when I close the form, during which I remove the reference to the querydef, the lock file keeps the accdb locked.

I have traced through the code several times to find what I am missing. I have tried several things, but I don't see anything else I can do, as you'll see in the following code snippets. Any clues?

Tom


The form is instantiated in a class file, and the querydef is attached to the subform:

Set frms(runNum) = New Form_frmOutput
frms(runNum).ResultsPane.SourceObject = "Query.qStrat" & runNum
frms(runNum).ResultsPane.Requery
frms(runNum).Init myParent, gdb, qdef.Name, "Select * from " & NewFile & ".StratsRun", Me
frms(runNum).Caption = formCaption
frms(runNum).txtHeading1 = gdb.getSettings("Heading1")
frms(runNum).txtHeading2 = gdb.getSettings("Heading2")
frms(runNum).txtHeading3 = gdb.getSettings("Heading3")
frms(runNum).Visible = True


NewFile is the external accdb.

Init doesn't really do anything with the querydef or the accdb file, but I figured I'd show it so you can follow the full process.

Public Function Init(ByRef stratform As Form_frmStrats, ByRef dbclass As CLASSDatabase, ByVal qdefname As String, _
ByVal querystring As String, ByRef strat As CLASSStrats) As Boolean

Set myParent = stratform
Set gdb = dbclass
Set cStrat = strat
myQuery = qdefname
txtQuery = querystring
txtHeading1 = gdb.getSettings("Heading1")
txtHeading2 = gdb.getSettings("Heading2")
txtHeading3 = gdb.getSettings("Heading3")
txtPageHeading = gdb.getSettings("PageHeading")
lblParams.Caption = ""

End Function


When the form is closing this code runs:

Private Sub Form_Unload(Cancel As Integer)

DoCmd.Close acQuery, myQuery

ResultsPane.SourceObject = ""
Me.Refresh
Set gdb = Nothing
Set myParent = Nothing

cStrat.ReleaseStrat Me.Caption
Set cStrat = Nothing

End Sub

gdb, myParent and cStrat are class file references. There are no others. ReleaseStrat just sets the form variable to Nothing.


Public Function ReleaseStrat(ByVal formName As String) As Boolean
Dim frm As Form_frmOutput
Dim i As Integer, ilimit As Integer

ilimit = UBound(frms)
For i = 0 To ilimit
If frms(i).Caption = formName Then
frms(i).ResultsPane.Enabled = False
frms(i).ResultsPane.SourceObject = ""
Set frms(i) = Nothing
End If
Next

End Function

 
This is resolved. I modified the SQL of the querydef to hit a local table rather than the external accdb. That released the lock file.

T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top