VB coding in Access  | |
May 9th, 2002, 07:08 AM
|
#1 (permalink)
| | Junior Member
Join Date: Apr 2002
Posts: 7
| VB coding in Access
I know nothing about VB and am little more than a beginner in Access. I'd be VERY grateful if someone could tell me how to code the following.
In the detail section of a report, I have a textbox that is bound to a field called Path, which contains the path and filename to a jpg image file, e.g. "D:\abc.jpg" without the quotes
I want the picture referred to by this image path to show
up in an unbound image frame called Photo (also in the detail
section).
I need the exact Code Builder coding that can accomplish this. My unproductive attempts have included the following statements in the detail section of the coding:
[Photo].Picture = [Path]
Me!Photo.Picture = Me!Path
Me.Photo.Picture = Me.Path
Me!Photo.Picture = Me!Path.Value
... and more
*sigh* |
| |
May 9th, 2002, 07:54 AM
|
#2 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 1,542
|
Here we are. Quote:
You can use a string expression that includes the path and the name of the graphic, as in the following example:
btnShowLogo.Picture = "c:\Windows\Winlogo.bmp"
| (MSAccess 2000 Help)
I think that Code: Me.Photo.Picture = Me![Path] should do it. |
| |
May 9th, 2002, 08:36 AM
|
#3 (permalink)
| | Junior Member
Join Date: Apr 2002
Posts: 7
|
Thanks for the reply, but ... I get a "Type mismatch error" with this coding:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Photo.Picture = Me![Path]
End Sub
You know how you get a dropdown menu of values of a field after you've typed it? Like when I type "Me.Photo." I get a dropdown list. But the strange thing is that there is no "Picture" value in that list. So as far as Access is concerned, Me.Photo.Picture does not exist. What gives?  |
| |
May 9th, 2002, 11:36 AM
|
#4 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 1,542
|
Ooh... First, let's check which version of Access you're running. I'm using 2000 btw.
Second, what object type is your Photo control? Like, in the Properties box, what does it say before the colon? e.g. Image: Photo. |
| |
May 9th, 2002, 05:57 PM
|
#5 (permalink)
| | Junior Member
Join Date: Apr 2002
Posts: 7
|
Access 2002 and it is Image: Photo
In Expression Builder, I am able to, through the expression elements subcategories, build an expression that goes like: [Photo].Picture = [Path]
But I've never figured out how to use Expression Builder in reports.
And translating that expression into the detail section of Code Builder does not seem to work. And I have tried the On Format, On Print and On Retreat sections (even though I don't understand what they mean).
Last edited by SlipGun : May 9th, 2002 at 06:10 PM.
|
| |
May 9th, 2002, 06:09 PM
|
#6 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 1,542
|
Sorry, perhaps things have changed with Access 2002. All I can really suggest is that you look in Help for the properties of the Image object, perhaps it'll say something in there... |
| |
May 9th, 2002, 06:15 PM
|
#7 (permalink)
| | Junior Member
Join Date: Apr 2002
Posts: 7
|
Most relevantcomment from Help is: Quote: |
You can also use a text field to store the location of pictures and then use those pictures in a form or report, but you must use Visual Basic event procedures to display the pictures.
| Not very helpful since it doesn't specify which VB functions I'd need. |
| |
May 9th, 2002, 08:32 PM
|
#8 (permalink)
| | Senior Member
Join Date: Oct 2001 Location: Alberta, Canada
Posts: 563
|
I'm a little tired and foggy right now, so bear with me for a sec...
try using LoadPicture( filename as string) in there. I presume something like Photo.Picture = LoadPicture(Path) . if it still isn't working, then I'd set a breakpoint on that line and see what's in the variables, if anything...
cya laters! need food so I can think again....  |
| |
May 9th, 2002, 10:28 PM
|
#9 (permalink)
| | ph34r t3h g04t
Join Date: Oct 2001 Location: Kingsford, MI
Posts: 19,557
|
Visual Basic event procedure = Form_Load? Form_Initialize? Etc?
Got me, but I figured I'd pitch one in.
-Whir |
| |
May 14th, 2002, 12:25 AM
|
#10 (permalink)
| | Junior Member
Join Date: Apr 2002
Posts: 7
|
Thanks for the replies. Just thought I'd say I got it working with the following coding:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
On Error Resume Next
Me!Photo.Picture = Me!Path
End Sub |
| | | Thread Tools | Search this Thread | | | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |