View Single Post
  #5  
Old February 27th, 2005, 10:03 PM
Michelle
external usenet poster
 
Posts: n/a
Default

Mark, Thanks! I appreciate the detail steps. And it's
embarrassing when I can't follow them!
I'm getting an error message: run-time error '2465'
Microsoft Access can't find the field 'FilePath' referred
to in your expresion. I can't get from design view to
form view because of it.

On my Animals table I added FilePath as a text field. And
in my Animals form (confusing names, I know) I added the
picture (which I had to put a box around so I could find
it!), deleted the actual picture/path and called the
field: ImageControl. Should the picture type be "linked"
rather than "embedded"?

Private Sub Form_Current()
Me.ImageControl.Picture = Me!FilePath
End Sub

I don't understand why this didn't work.

So I commented it out, and then I get a compile error:
expected variable or procedure, not module
and remembered to name the module: GetTheFilenamemdl
rather than GetTheFilename. See! I can be taught.

Now, it's not liking
Dim dlgFilePick As FileDialog
I've never seen FileDialog. This must be what you
mentioned as tweaking the file browser function as I'm
using Access 2000. So I took a peek in the library and I
have these checked (and in this order):
VB for applications
Microsoft Access 9.0 object library
OLE Automation
Microsoft DAO 3.6 object library
Microsoft ActiveX Sata Objects 2.1 library

Am I salvagable? Thanks for your help, Michelle

-----Original Message-----
Hi Michelle,

For testing, you can certainly just type in the full path

(don't need
quotes) to the image (don't forget the file's extension

like Dog1.jpg). On
the form, add an image and select any old image from the

wizard. Once the
control is on the form, you can go to properties and

erase the file path in
the "Picture" property. Now you have a blank (unbound)

image control.

In my test form I whipped up to refresh my memory, I just

used the default
name of the control, which happened to be "Image7".

Since the file path is
saved with the record, you'll always get the correct

image for the record
being displayed.

When your user clicks on the image (or blank image box if

there's no image
assigned yet), the full filename with path is stored in

the FilePath field
for that record and the form's recordset is requeried to

update the image.
The ImageControl's OnClick event:
'*********code start************
Private Sub ImageControl_Click()
Dim strFilename As String, strFind As String
Dim lngID As Long

strFilename = GetTheFilename("Browse to the file")
If strFilename = "Cancelled" Then
Exit Sub
End If
Me!FilePath = strFilename
lngID = Me!ItemID
strFind = "[ItemID]=" & lngID
Echo False
Me.Requery
Me.Recordset.FindFirst strFind
Echo True

'********code end************

In a regular module (for the file requestor),
'********code start********
Function GetTheFilename(strTitle As String) As String
Dim strFilename As String
Dim dlgFilePick As FileDialog
Dim vrtSelectedItem As Variant

On Error GoTo Err_GetFilename
Set dlgFilePick = Application.FileDialog

(msoFileDialogFilePicker)
With dlgFilePick
.Title = strTitle
'Let user select only one file
.AllowMultiSelect = False
If .Show = -1 Then
'The user pressed the action button.
GetTheFilename = .SelectedItems(1)

Else
'The user pressed Cancel.
GetTheFilename = "Cancelled"
End If
End With

Exit_GetFilename:
Set dlgFilePick = Nothing
Exit Function
Err_GetFilename:
MsgBox "Error " & Err.Number & ": " &

Err.Description, ,
"GetTheFilename"
Resume Exit_GetFilename
End Function
'********code end************

I'm using Access2003, so the file browser function might

need tweaking for
older versions.
Hope this helps!

"Michelle" wrote in

message
...
I like the sound of that! I only have 5 pictures so far
and they are slow to load.

I want to try it! I created a new text field (FilePath)

in
table Animals. My file path for the 1st picture is
C:\My Documents\My Pictures\Dog1
so I enter the above path in the Animals table, FilePath
field for Dog1's record. Correct? Do I need the file
path in quotes?

How do I create an unbound image control on the form? I
see the tool bar offers "image", "unbound object frame"
and a "bound object frame"- all of which want me to

select
the image now. What am I missing to get an unbound

image
control?

I'm confused about: Me.Image7.Picture = Me!FilePath
Does Image7 mean something? Is that the name of your
image in the record? If so, how does the record know
which picture to show for which record- must be by the
file path name...

You said "When you click the image control, the user
browses to the picture they want to assign to the

current
record."- that sounds cool! So I set up the unbound

image
control once in the table and then the user gets to

choose
the picture, so that the user is never in the table-
correct? That would be excellent!

Thanks for the guidance!
Michelle

-----Original Message-----
I used to have an ID badge database that stored the

digital pictures in an
OLE field. There was an OLE control on the form which,

when clicked, would
let you browse to select the file. With only 100 or so

employee records, the
database bloated to over 200Mb. I have since modified

the database to get
rid of the OLE field and control. I'm now storing the

path to the picture
in a text field called FilePath and the database is

under
200Kb. I've got
an unbound image control on the form, and in the form's

OnCurrent event I
have:

Me.Image7.Picture = Me!FilePath

which will change the picture to match the picture you

assigned to the
current record. When you click the image control, the

user browses to the
picture they want to assign to the current record. It

works with both JPG
and BMP files.

"Michelle" wrote in

message
.. .
Sorry about that!
I have form that I want to show a digital camera

picture.
I have the table field set up as an OLE Object.

Can I load the picture from the form, or do I need to

go
to the table, find the correct record for the field,
select Insert object and the browse to the correct

digital
camera picture? There's got to be an easier way for

end-
users!

I see that bitmap is an option, but my digital camera
pictures are jpg. How do I upload these?

Thanks,
Mich


.




.