home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

VB coding in Access

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2132
Discussions: 200,947, Posts: 2,379,387, Members: 246,309
Old May 9th, 2002, 07:08 AM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Apr 2002
Posts: 7
Angry
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*
SlipGun is offline   Reply With Quote
Old May 9th, 2002, 07:54 AM     #2 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
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.
strangerstill is offline   Reply With Quote
Old 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?
SlipGun is offline   Reply With Quote
Old May 9th, 2002, 11:36 AM     #4 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
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.
strangerstill is offline   Reply With Quote
Old 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.
SlipGun is offline   Reply With Quote
Old May 9th, 2002, 06:09 PM     #6 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
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...
strangerstill is offline   Reply With Quote
Old 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.
SlipGun is offline   Reply With Quote
Old 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....

^hyd^ is offline   Reply With Quote
Old May 9th, 2002, 10:28 PM     #9 (permalink)
ph34r t3h g04t
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 19,557
Blog Entries: 7
Visual Basic event procedure = Form_Load? Form_Initialize? Etc?

Got me, but I figured I'd pitch one in.

-Whir
Whir is offline   Reply With Quote
Old 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
SlipGun is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Making Health Care Worse (170)
The disrespect of Obama by Russian .. (22)
Is It Just Me? (2934)
Wireless Televisions. (11)
windows 7 problem (7)
CPU fan stops spinning randomly (8)
Regular Build (6)
Is the PSU I received dead? (12)
radeon x850xt platinum & shader.. (5)
Print spooler problem (15)
HIS HD5770 graphic card question (15)
windows vista security holes (9)
Install XP pro and a Vista laptop ?.. (11)
Foreign voltage (10)
Recent Discussions
Internet Lost (1)
Hp Artist Edition + Matching Bag (0)
My monitor won't turn on after instal.. (0)
Graphics Card Upgrade Question (2)
Asus P4G8X Mobo (6)
radeon x850xt platinum & shader 3 (5)
Xbox 360 GTA: SA disk error (1)
Is the PSU I received dead? (12)
How to convert MP3's (2)
windows 7 internet problem (5)
Multiple Restarts Required at Boot (0)
BSOD On Startup (ntoskrnl.exe) (2)
Print spooler problem (15)
Laptop with wireless problem. (1)
Wireless Televisions. (11)
Have you switched yet? (86)
screen resolution vs monitor size (2)
sms storage to PC (0)
Regular Build (6)
Open With ..... Win7 (0)
java code for fibonacci (1)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (35)
windows 7 problem (7)
CPU fan stops spinning randomly (8)
Partition Magic caused HDD problem (3)


All times are GMT -4. The time now is 08:27 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28