Why is the picture file name stored in a separate table? Can't it be
included in the same table as the rest of the member's information? I
don't
know all the details about your database, but I've never had the picture
file name stored separately from the rest of the information because it's
part of that information. By storing it in the same table, you eliminate
the
need to have any kind of primary key associated with the file and you can
also leave the file name blank and use the default picture (as the code
shows). I'm not sure I would set the default value of a table field to a
file, because if the file ever moves or the name changes you would have
to
edit your table design.
If there is a need for what you're doing, then I'm not sure how you'd go
about ensuring that every member record has a corresponding picture
record.
Possibly make an entry in the picture file table whenever a new member
record is created. Again, not knowing your application it's hard to
suggest
anything more specific.
As to your last question, the main difference between your code and my
suggestion is that my suiggestion would not alter what the user entered
into
the image path field. Since the pictures are always stored in the same
folder, there is no need to store that folder as part of the file name.
If
it were me, what I would do is create a table to store the picture file
path
and use that to build the complete file name. That way, if you ever want
to
move your picture files all you have to do is change the value in that
table; no code changes would be required.
Carl Rapson
Frank Situmorang said:
Thanks Carl for your suggestion, however maybe I need to tell your more
information. The photo Tab and member's general information are based
on
differenct tables. I made a link between parent and child ( image path
is
child).
Since the idea is also if imagepath is blank it will show up the
nopicture.jpg, how can I make it works like that. The problem also is
like
this, member record number 1 has photo, number 2 has not submitted yet
his/her photo, number 3 already summitted. if I filled member record
number 3
it can not be done because it will skip number 2 while there is and
primary
key of the photoID which can not be left blank. Could I make the
defalut
value of image path field as " no picture"?.
On your suggestion what is the different between it and this:
Me.ImageFrame.Picture = Me.ImagePath
Will your suggestion give different effect?
Thanks in advance
--
H. Frank Situmorang
:
Not sure if this is the issue, but in the AfterUpdate event I would
add
the
file path like this:
Me.ImageFrame.Picture = "C:\churchdata\" & Me.ImagePath
I would also add an Else clause in case the user cleared the ImagePath
field:
Else
Me.ImageFrame.Picture = "C:\churchdata\Nopicture.jpg"
Carl Rapson
Hello,
This is my VBA to update the pictures of the members. For your info,
there
several tabs to update the member information including the photos.
When we update the photo by typing in the image path it does not
automatically show up the picures. We have to go backward to the
previous
record then we go again to this record then we can see the photo.
My question how can we make it as we entered the imagepath field it
will
show up the photo.
This iis my VBA:
Private Sub Form_Current()
On Error Resume Next
If Not (IsNull(Me.ImagePath)) Then
Me.ImageFrame.Picture = Me.ImagePath
Else
Me.ImageFrame.Picture = "C:\churchdata\Nopicture.jpg"
End If
End Sub
Private Sub ImagePath_AfterUpdate()
On Error Resume Next
Me!ImagePath = "C:\churchdata\" & Me![ImagePath]
If Not (IsNull(Me.ImagePath)) Then
Me.ImageFrame.Picture = Me.ImagePath
End If
End Sub.
Thanks in advance for any help.