Code from 2003 no longer works on 2007

G

Guest

I barely know enough about Microsoft Access to get by and I created a program
for work that keeps track of inventory and uses a visual basic code to pull
up pictures in forms. This has always worked great on Access 2003 but since
we upgraded to 2007 this no longer works. If anyone could please tell me what
I need to do to this code to get it to work in 2007 I would greatly
appreciate it.

Option Compare Database

Private Sub Form_Current()
On Error GoTo err_Form_Current

If Not Me!txtPicture = "" Or Not IsNull(Me!txtPicture) Then
Me!Picture.Picture = GetPathPart & Me!txtPicture
Else
Me!Picture.Picture = ""
End If

If Not Me!txtPicture2 = "" Or Not IsNull(Me!txtPicture2) Then
Me!Picture2.Picture = GetPathPart & Me!txtPicture2
Else
Me!Picture2.Picture = ""
End If

If Not Me!txtPicture3 = "" Or Not IsNull(Me!txtPicture3) Then
Me!Picture3.Picture = GetPathPart & Me!txtPicture3
Else
Me!Picture3.Picture = ""
End If

exit_Form_Current:
Exit Sub

err_Form_Current:
MsgBox Err.Description
Resume exit_Form_Current
End Sub

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open

If IsNull(Me!txtPicture) Or Me!txtPicture = "" Then
' do nothing
Else
Me!Picture.Picture = GetPathPart & Me!txtPicture
End If

If IsNull(Me!txtPicture2) Or Me!txtPicture2 = "" Then
' do nothing
Else
Me!Picture2.Picture = GetPathPart & Me!txtPicture2
End If

If IsNull(Me!txtPicture3) Or Me!txtPicture3 = "" Then
' do nothing
Else
Me!Picture3.Picture = GetPathPart & Me!txtPicture3
End If


Exit_Form_Open:
Exit Sub

Err_Form_Open:
MsgBox Err.Description
Resume Exit_Form_Open

End Sub
 
A

Allen Browne

In Access 2007, go to:
Office Button | Access Options | Trust Center | Trusted Locations

Add the folder where you keep your databases to the trusted locations.

If the code is for Image controls, you may be interested to know that the
Image Control in A2007 now has a Control Source. You can just set the
Control Source to an expression such as:
= GetPathPart & Me!txtPicture
and it works without code.

More info about the new version:
http://allenbrowne.com/Access2007.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 

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