Error 2220 after opening the database

Schippi

New member
Local time
Today, 17:59
Joined
Jun 1, 2011
Messages
9
Hi,

I have a funny bug in my code, which only gets active after the database was opened again. I have a Treeview on a form with the organization data in it. The data is stored in a Table and via a query it is transferred in the correct fitting. Now the problem is that when I klick on the Treeview the error message 2220 XX can not open file 'XXX.bmp'. It does not work for any of the customer. When I go into the Contact Form and delete the image and reasign it, the error disapears. This has to be done for one record and afterwards it is no problem for any picture.

so here is the code.

Code:
Private Sub xTree_NodeClick(ByVal Node As Object)
Dim ContactID As Integer
Dim TableQuery As String
Dim Selector As Variant
On Error GoTo handler
ContactID = CInt(Mid(Node.Key, 2)) ' get the node key that the employee relates to when licked.
TableQuery = "LookupTreeviewQyr"
Selector = "ContactID=" & ContactID   'get the staff information and compare it to the selected node.
Me.JobTitle = DLookup("[Job Title]", TableQuery, Selector)
Me.FirstName = DLookup("Name", TableQuery, Selector)
Me.Email = DLookup("[E-mail Address]", TableQuery, Selector)
Me.Mobile = DLookup("[Mobile Phone]", TableQuery, Selector)
Me.Business = DLookup("[Business Phone]", TableQuery, Selector)
Me.Located = DLookup("[Located in]", TableQuery, Selector)
Me.Importance = DLookup("[Importance]", TableQuery, Selector)
Me.Relation = DLookup("[Relation]", TableQuery, Selector)
Me.Objectives = DLookup("[Main objectives]", TableQuery, Selector)
Me.StaffPhoto.Picture = DLookup("[Picture]", TableQuery, Selector)
exithandler:
    Exit Sub
handler:
    If Err.Number = 0 Then
        Resume Next
    ElseIf Err.Number = 94 Then ' if the employee does not have a photo show nothing
        Me.StaffPhoto.Picture = ""
        Resume Next
    Else
      MsgBox Err.Number & "  " & Err.Description
        GoTo exithandler
    End If
End Sub
 
I made a workaround which is working pretty well: I added in field Picture in my query the function CurrentProject.Path and the folder path with the pictures so that access always updates the path.
 

Users who are viewing this thread

Back
Top Bottom