A family of Microsoft relational database management systems designed for ease of use.
It might help if you provided the code. Does the user have delete permissions in the folder?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Microsoft Access is opening and leaving a copy of Access running in the background upon closing the application. This prevents the user from re-opening the application later, but it throws no error message.
I have looked at the code that does reference opening the Current Database and updates a Query Definition. The code closes the variable references to both the database and the Query Definition. It sets both variables to Nothing. I monitor the Task Manager and the background copy of Access does not appear until the Access Application is closed.
I can post the code if that would help. Any other suggestions?
Thanks.
-Vernon
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
It might help if you provided the code. Does the user have delete permissions in the folder?
There is another function lstBoxInBoundData() that we don’t know the code. I’m not optimistic the issue is there.
After I run the button click below, I get another instance of Access appearing in the Task Manager when I close the application. I have tried many things, but here is the current state of the code as of now.
It does not appear while the application is running, only when closing.
Thanks,
-Vernon
'***** Updated to add the code for the UpdateListCount Sub ********
Private Sub pbSelStation_Click()
SelectAll ([Forms]![frmPrintQueryByFormSingle].lstStation)
lstStation\_AfterUpdate
UpdateListCounts
End Sub
Public Function SelectAll(lst As ListBox) As Boolean
'Iterate through Listbox control - select all items
On Error GoTo Err\_SelectAll
Dim lngRow As Long
If lst.MultiSelect Then
For lngRow = 0 To lst.ListCount - 1
lst.Selected(lngRow) = True
Next
SelectAll = True
End If
Exit_SelectAll:
Exit Function
Err_SelectAll:
Call ErrorMsg(err.Number, err.Description, vbExclamation)
Resume Exit\_SelectAll
End Function
Private Sub lstStation_AfterUpdate()
On Error GoTo err:
Dim str As String
'MsgBox " Populate this box with Part Number and CMA Location for the Route: " & Forms!frmPrintQuerybyFormSingle!lstPartNumber
'str = lstBoxBoundData(lstRouteStation, "[CMA Aisle]")
Dim CriteriaStr As String
Dim sqlStr As String
Dim sqlStrC As String
'Dim db As DAO.Database
'Set db = CurrentDb
Dim qdf As DAO.QueryDef
' Get sql Criteria string from Listbox
'Update the Partnumber Listbox
'
If frameLabelType = CMALabelReport Then
CriteriaStr = lstBoxInBoundData(lstStation, "[Location]")
'CriteriaStr = lstBoxBoundData(lstStation, "[Location]")
'lstBoxInBoundData
ElseIf frameLabelType = GFRLabelReport Then
CriteriaStr = lstBoxBoundData(lstStation, "[Station]")
ElseIf frameLabelType = Bulk11x17Report Then
CriteriaStr = lstBoxBoundData(lstStation, "[delivery route]")
ElseIf frameLabelType = Bulk34x22Report Then
CriteriaStr = lstBoxBoundData(lstStation, "[delivery route]")
End If
'
' Build full Sql String
'SqlStr = "SELECT DISTINCT [PFEP Label DB 110122].[Base 8],[Location] "
If CriteriaStr & "" = "" Then
sqlStr = "SELECT distinct [PFEP Label DB 110122].[Part Number] , [Location] " & \_
"FROM [PFEP Label DB 110122] " & \_
" where([Part Description] = '-99')" & \_
" ORDER BY [PFEP Label DB 110122].[Part Number];"
ElseIf frameLabelType = CMALabelReport Then
sqlStr = "SELECT distinct [PFEP Label DB 110122].[Part Number] , [location], [PartStation], [station] " & \_
"FROM [PFEP Label DB 110122] " & \_
" where( " & CriteriaStr & ")" & " And Shop = '" & Me.lstShop.Value & "' " & \_
" And [Delivery Method] = 'Small Lot' " & \_
" ORDER BY [PFEP Label DB 110122].[Part Number];"
ElseIf frameLabelType = GFRLabelReport Then
sqlStr = "SELECT distinct [PFEP Label DB 110122].[Part Number] , [Station], [PartStation] " & \_
"FROM [PFEP Label DB 110122] " & \_
" where( " & CriteriaStr & ")" & " And Shop = '" & Me.lstShop.Value & "' " & \_
" And [Delivery Method] = 'Small Lot' " & \_
" ORDER BY [PFEP Label DB 110122].[Part Number];"
ElseIf frameLabelType = Bulk11x17Report Then
sqlStr = "SELECT distinct [PFEP Label DB 110122].[Part Number] , [Station], [PartStation] " & \_
"FROM [PFEP Label DB 110122] " & \_
" where( " & CriteriaStr & ")" & " And Shop = '" & Me.lstShop.Value & "' " & \_
" And [Delivery Method] = 'Bulk' " & \_
" ORDER BY [PFEP Label DB 110122].[Part Number];"
ElseIf frameLabelType = Bulk34x22Report Then
sqlStr = "SELECT distinct [PFEP Label DB 110122].[Part Number] , [location], [PartStation] " & \_
"FROM [PFEP Label DB 110122] " & \_
" where( " & CriteriaStr & ")" & " And Shop = '" & Me.lstShop.Value & "' " & \_
" And [Delivery Method] = 'Bulk' " & \_
" ORDER BY [PFEP Label DB 110122].[Part Number];"
End If
' SqlStrC = "SELECT distinct [PFEP Label DB 110122].[Station] , [Base 8], [PartStation] " & _
' "FROM [PFEP Label DB 110122] " & _
' " where( " & CriteriaStr & ")" & _
' " ORDER BY [PFEP Label DB 110122].[Station];"
'
'
' Replace the Query Definition using the new SQL String
If frameLabelType <> Bulk11x17Report And frameLabelType <> Bulk34x22Report Then
'Set qdf = db.QueryDefs("04BqryRouteSmallLotCMALabel")
Set qdf = CurrentDb.QueryDefs("04BqryRouteSmallLotCMALabel")
qdf.SQL = sqlStr
Me.lstPartNumber.RowSource = "04BqryRouteSmallLotCMALabel"
Me.lstPartNumber.RowSourceType = "Table/Query"
Me.lstPartNumber.Requery
ElseIf frameLabelType = Bulk11x17Report Or frameLabelType = Bulk34x22Report Then
Set qdf = CurrentDb.QueryDefs("04BqryRouteSmallLotCMALabel")
qdf.SQL = sqlStr
Me.lstPartNumber.RowSource = "04CqryRouteSmallLotCMALabel"
Me.lstPartNumber.RowSourceType = "Table/Query"
Else
End If
DoEvents
' Update the list counts
'
ExitSub:
'If Not db Is Nothing Then
' db.Close
' Set db = Nothing
'End If
If Not qdf Is Nothing Then
qdf.Close
Set qdf = Nothing
End If
DoEvents
UpdateListCounts
Exit Sub
Public Function lstBoxInBoundData(lst As ListBox, strField As String) As String
Dim frm As Form, ctl As Control
Dim varitem As Variant
Dim str As String
Set frm = Forms!frmPrintQueryByFormSingle
Set ctl = lst
str = ""
If lst.ItemsSelected.Count = 0 Then
' Should never get here
'
MsgBox "There are no items selected", vbOKOnly, "Select " & strField & " to Print"
Exit Function
Else
For Each varitem In ctl.ItemsSelected
If str & "" <> "" Then
str = str & ", '" & lst.ItemData(varitem) & "' "
Else
str = strField & " in ('" & lst.ItemData(varitem) & "' "
End If
Next varitem
str = str & ")"
End If
lstBoxInBoundData = str
Exit_lstBoxBoundData:
Exit Function
Err_lstBoxBoundData:
Call ErrorMsg(err.Number, err.Description, vbExclamation)
Resume Exit\_lstBoxBoundData
End Function
Private Sub UpdateListCounts()
Me.lblRouteCount.Caption = "Routes: " & Me.lstRouteStation.ListCount
Me.lblStationCount.Caption = "Stations: " & Me.lstStation.ListCount
Me.lblCountByParts.Caption = "Parts: " & Me.lstByParts.ListCount
Me.lblPartNumbers.Caption = "Tagged Parts: " & Me.lstPartNumber.ListCount
Me.lblSelRoutes.Caption = "Sel Routes: " & Me.lstRouteStation.ItemsSelected.Count
Me.lblSelStations.Caption = "Sel Stations: " & Me.lstStation.ItemsSelected.Count
Me.lblSelByParts.Caption = "Sel Parts: " & Me.lstByParts.ItemsSelected.Count
Me.lblSelPartNumbers.Caption = "Print Parts: " & Me.lstPartNumber.ItemsSelected.Count
End Sub
I am having the same issue on my own machine used for development and I have administrative privileges. I am including the code in question to see if it will help.
Thanks,
-Vernon
One way this can happen is if some user does not have Write or Delete privileges on the folder containing the backend. Access creates a .laccdb file in that folder on opening Access, and deletes it at close; if the deletion is prohibited, it will hang in this way.