pix on my database

J

Jeannette

hello from spain
sorry for my poor english
My knowledge with this program are little, but something I have obtained.
I´m creating my own database with photos, I have obtained that the photos
appear thanks to the code that saw on Neptune (example in access) but if I
change the route (?) of the photo, this doesn´t appear in my database, why?
this is the code in my database that I copied from example Neptune
what´s the wrong? I need that you help me to complete satisfactorily this
code? please!!!!!!!
thanx

Private Sub Form_RecordExit(Cancel As Integer)
ErrorMsg.Visible = False
End Sub

Private Sub removepicture_Click()
Me![ImagePath] = ""
hideImageFrame
ErrorMsg.Visible = True
End Sub

Private Sub Form_AfterUpdate()
Me![IdFotografia].Requery
On Error Resume Next
showErrorMessage
showImageFrame
If (IsRelative(Me!ImagePath) = True) Then
Me![ImageFrame].Picture = Path & Me![ImagePath]
Else
Me![ImageFrame].Picture = Me![ImagePath]
End If
End Sub

Private Sub ImagePath_AfterUpdate()
On Error Resume Next
showErrorMessage
showImageFrame
If (IsRelative(Me!ImagePath) = True) Then
Me![ImageFrame].Picture = Path & Me![ImagePath]
Else
Me![ImageFrame].Picture = Me![ImagePath]
End If
End Sub

Private Sub Form_Current()
Dim res As Boolean
Dim fName As String

Path = CurrentProject.Path
On Error Resume Next
ErrorMsg.Visible = False
If Not IsNull(Me![Foto]) Then
res = IsRelative(Me![Foto])
fName = Me![ImagePath]
If (res = True) Then
fName = Path & "\" & fName
End If

Me![ImageFrame].Picture = fName
showImageFrame
Me.PaintPalette = Me![ImageFrame].ObjectPalette
If (Me![ImageFrame].Picture <> fName) Then
hideImageFrame
ErrorMsg.Caption = "No se encuentra la imagen"
ErrorMsg.Visible = True
End If
Else
hideImageFrame
ErrorMsg.Caption = "Hacer clic en Obtener para agregar o cambiar
imagen"
ErrorMsg.Visible = True
End If

End Sub

Sub getFileName()
Dim fileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Seleccione la imagen"
.Filters.Add "Todas las imagenes", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 2
.Filters.Add "GIFs", "*.gif"
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![IdFotografia].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

Sub showErrorMessage()
If Not IsNull(Me![Foto]) Then
ErrorMsg.Visible = False
Else
ErrorMsg.Visible = True
End If
End Sub
Function IsRelative(fName As String) As Boolean
IsRelative = (InStr(1, fName, ":") = 0) And (InStr(1, fName, "\\") = 0)
End Function

Sub hideImageFrame()
Me![ImageFrame].Visible = False
End Sub

Sub showImageFrame()
Me![ImageFrame].Visible = True
End Sub
 
D

Douglas J. Steele

How does the function IsRelative determine whether or not a path is
Relative? Also, is Path declared as a variable outside of the code you
presented?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Jeannette said:
hello from spain
sorry for my poor english
My knowledge with this program are little, but something I have obtained.
I´m creating my own database with photos, I have obtained that the photos
appear thanks to the code that saw on Neptune (example in access) but if I
change the route (?) of the photo, this doesn´t appear in my database,
why?
this is the code in my database that I copied from example Neptune
what´s the wrong? I need that you help me to complete satisfactorily this
code? please!!!!!!!
thanx

Private Sub Form_RecordExit(Cancel As Integer)
ErrorMsg.Visible = False
End Sub

Private Sub removepicture_Click()
Me![ImagePath] = ""
hideImageFrame
ErrorMsg.Visible = True
End Sub

Private Sub Form_AfterUpdate()
Me![IdFotografia].Requery
On Error Resume Next
showErrorMessage
showImageFrame
If (IsRelative(Me!ImagePath) = True) Then
Me![ImageFrame].Picture = Path & Me![ImagePath]
Else
Me![ImageFrame].Picture = Me![ImagePath]
End If
End Sub

Private Sub ImagePath_AfterUpdate()
On Error Resume Next
showErrorMessage
showImageFrame
If (IsRelative(Me!ImagePath) = True) Then
Me![ImageFrame].Picture = Path & Me![ImagePath]
Else
Me![ImageFrame].Picture = Me![ImagePath]
End If
End Sub

Private Sub Form_Current()
Dim res As Boolean
Dim fName As String

Path = CurrentProject.Path
On Error Resume Next
ErrorMsg.Visible = False
If Not IsNull(Me![Foto]) Then
res = IsRelative(Me![Foto])
fName = Me![ImagePath]
If (res = True) Then
fName = Path & "\" & fName
End If

Me![ImageFrame].Picture = fName
showImageFrame
Me.PaintPalette = Me![ImageFrame].ObjectPalette
If (Me![ImageFrame].Picture <> fName) Then
hideImageFrame
ErrorMsg.Caption = "No se encuentra la imagen"
ErrorMsg.Visible = True
End If
Else
hideImageFrame
ErrorMsg.Caption = "Hacer clic en Obtener para agregar o
cambiar imagen"
ErrorMsg.Visible = True
End If

End Sub

Sub getFileName()
Dim fileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Seleccione la imagen"
.Filters.Add "Todas las imagenes", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 2
.Filters.Add "GIFs", "*.gif"
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![IdFotografia].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

Sub showErrorMessage()
If Not IsNull(Me![Foto]) Then
ErrorMsg.Visible = False
Else
ErrorMsg.Visible = True
End If
End Sub
Function IsRelative(fName As String) As Boolean
IsRelative = (InStr(1, fName, ":") = 0) And (InStr(1, fName, "\\") = 0)
End Function

Sub hideImageFrame()
Me![ImageFrame].Visible = False
End Sub

Sub showImageFrame()
Me![ImageFrame].Visible = True
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