Access 2003 breaks form coded in 2002?

T

tpcolson

The code pasted below was written by a now "not working with us"
developer to display a series of pictures in a multipage form. Some
background: The form is used to record information about ecological
surveys, which involve counting lots of trees. For each survey site, 3
pictures are taken and the images are given a unique name, XXXXXXA.jpg,
XXXXXXE.jpg, and XXXXXXN.jpg, for a picture of the site, a picture
north of the site, and a picture east of the site. The VB code would
display the appropriate picture in the appropriate box on the form, and
the forms were filtered on the site unique identifier. I'd like to
emphasize strongly that this worked PERFECTLY in Access 2002. No bugs,
no crashes, worked great for 18 months.

Then we upgraded the lab to Office 2003.

As soon as the form is opened..the following error appears: "Run time
error '2753': A problem occured while microsoft access was
communicating with the OLE server or Active X control."

Running debugger highlights the following line:

Me.Image_a.Action = acOLECreateLink

In the 2002 version of this, the following reference were "checked":
Visual Basic for Apps
MS Access 10.0 object library
MS Active X Data Objects 2.1 Library
MS Office XP Web components
OLE Automation.

In the 2003 version the only difference is the MS Access 10.0 Object
Library is now the MS Access 11.0 Object Library.

I tried replacing the 11.0 Library with the 10.O library, same error.
I've set macro security to none. I've held a feather over my head and
chanted buddhist prayers. No one around here could write 10 lines of VB
code to save their lives. This IS an academic lab.....

The path of all the db files and pictures has not changed, as this is
all on the same, orginal machine.

I'm thinking the error here is incompatibility with object libraries.
Two questions here...what do I have to check to make this work, and why
do new releases of MS software break everything developed with older
versions?


Option Compare Database
Dim strPath As String

Private Sub Form_Current()
'If there is an image name in the record then set the source file to
the
'file path of the image. If there is no picture, set the file path to
the
'path of the NoPicture.jpg image which is a blank picture. Do this for
each
'of the three image objects.

If Not IsNull(Me.Picture_a.Value) Or Trim(Me.Picture_a.Value) > "" Then
Me.Image_a.SourceDoc = strPath + "pictures\" + Me.Picture_a.Value
Me.Image_a.Action = acOLECreateLink
Else
Me.Image_a.SourceDoc = strPath + "pictures\NoPicture.jpg"
Me.Image_a.Action = acOLECreateLink
End If
If Not IsNull(Me.Picture_n.Value) Or Trim(Me.Picture_n.Value) > "" Then
Me.Image_e.SourceDoc = strPath + "pictures\" + Me.Picture_e.Value
Me.Image_e.Action = acOLECreateLink
Else
Me.Image_e.SourceDoc = strPath + "pictures\NoPicture.jpg"
Me.Image_e.Action = acOLECreateLink
End If
If Not IsNull(Me.Picture_e.Value) Or Trim(Me.Picture_e.Value) > "" Then
Me.Image_n.SourceDoc = strPath + "pictures\" + Me.Picture_n.Value
Me.Image_n.Action = acOLECreateLink
Else
Me.Image_n.SourceDoc = strPath + "pictures\NoPicture.jpg"
Me.Image_n.Action = acOLECreateLink
End If
End Sub

Private Sub Form_Load()
Dim cn As ADODB.Connection
Dim i As Integer
Dim intpos As Integer

'Set connection to current database
Set cn = CurrentProject.AccessConnection

'Gets full path for current database including file name
strPath = cn.Properties("Data Source")

'Gets position of last slash
For i = 1 To Len(strPath)
If Mid(strPath, i, 1) = "\" Then
intpos = i
End If
Next i

'Strips file name off full path
strPath = Mid(strPath, 1, intpos)
'Closes connection
cn.Close
Set cn = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top