Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picture in my report 34

Status
Not open for further replies.

strantheman

Programmer
Mar 12, 2001
333
US
Ive searched all of the Access forums, and I haven't found a solution that works. This seems like a very common procedure so im sure someone out there can help.

My ITEM table looks like this:

name | imagepath
-----------------------------------------------
Linksys Cable/DSL Router | d:\lsBEFSR41.jpg
Netgear Switch | d:\ngFS105.jpg

Name is the name of the product, and imagepath is where the photo is stored on my drive. My report pulls NAME, IMAGEPATH from ITEM table for the specified ID. I want to show the name of the product, and its corresponding picture on my report.

For this discussion, lets say the two objects on my report are named itemName and itemImage. I would assume this is as simple as setting some property of itemImage to the IMAGEPATH field, but ive been unable to figure this out. Please provide any help that you can. Id be willing to receive an email with a sample MDB file if thats what I have to do.

thanks in advance, im really hurtin here.
 
Put the following code behind a command buttons On Click event procedure:

Code:
MsgBox "Relative Path to Picture: " & vbCrLf & vbCrLf & Me![[i]controlname[/i]].Picture

This is just an example. Update the control name of your Image control and whatever you have inserted here to bring up this picture will be displayed in a MsgBox.

Hope this is what you are looking for.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
I don't believe I was clear on what I wanted. More likely than not overexcitement on getting the first half of the thing to work.

I'd like the command button on click to choose a file and path and put it in a text box of the form.

I.E. You click on the button, you'll get a window to choose what file you want, you choose that file and the whole shooting match (like m:\folder\file.jpg) goes into the text box.



jacque
 
Sure that can be done but once again you are hard embedding a link into the table. The discussion above is important to note in that rather than embedding the link we are using data stored in the fields of the record and when you puruse through the records the path and picture image changes with the code from the record.

Is this what you want to happen.

[COLOR=006633]Bob Scriver[/color]



 
Hey Bob, If I understand correct yes, I want to "hard embed" a link into the table via the form.

I would like the file path/link to stay inside the table.

 
I think I may be getting close, should I be doing something with the DEEfunction or DDESend?

j

Just knowlegeable enough to cause problems.
 
You want to have ACCESS bring up a browse window for you to pick a path and have the path saved in your table as the path to the picture?


[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Do you want to store just the path to the folder or to include the actual file also?

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Just the path

Man! Your good, you ask good questions.

j

Just knowlegeable enough to cause problems.
 
I can give you the code to do this but if you read above the technique for changing images with each record only requires you to store the path to the folder just once. Store it in a parameters table and read it upon starting up the database into a global variable and you can then just cancatenate this path variable to the records image name and place that in the image controls .picture property. No need to do this for each record. I also recommend that all the pictures go in one folder and the name of the picture be related to the RecordID or some unique field in the record. This way you don't have to store anything new and just use this one path plus the already existing field to find your picture and display it.

Clear as mud right??? Post back with questions if you have them.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Actually I do understand, let me tell you what I'm doing;

I work as a security officer in a large exclusive (kind of) privately owned hotel.

We often trespass people and take a digital picture which goes to E:\security of our computer.

I have a form built to tell a user about that person and have a text box and picture frame all working ok with each other to pull the picture off of e:\security.

In trying to make it as easy as possible for the non-computer literate people I'd like them to be able to use that command button to choose the file and have it automatically paste into the text box which will automatically update the form with the picture.

Whew! Have I muddied up the waters some more?



Just knowlegeable enough to cause problems.
 
How do you name the pictures and identify the records in your system? This is where it is really slick. When you save the picture save it as the ID of the record(i.e. A1234.jpg) The records ID is A1234 or a Name or whatever you call it. The form would bring up the record and use the stored path plus the record ID to bring up the picture. Does that sound like it works.

When you tell the user to bring up the record how do they know what to look for. Is there an incident# or trespasser# or something like that. Just name the file that same idetnification plus .jpg.

Let me know which way you want to go.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
We name the pictures the name of the subject we are trespassing (Jones, Hendrix, Scriver) etc. It makes it easier to find the pictures if we want a stand alone picture for printing to the police or whomever.

"The form would bring up the record and use the stored path plus the record ID to bring up the picture. Does that sound like it works."

That is exactly how I have it set up now.

Where I got stumped is the command button to pasting the path in the text box.

j


Just knowlegeable enough to cause problems.
 
Sorry. I am making this too difficult. I got confused by your command button. There is no need for the command button. When you bring up the record the VBA code to paste the path and picture name goes in the FORMS On Current event procedure. Just create this event procedure and put your code and ". . . when the focus moves to a record, making it the current record, or when the form is refreshed or requeried." the picture will be refreshed.

Code:
Me![[i]imagecontrolname[/i]].picture = vPathstring & Me![[i]idcontrol[/i]]

Post back with questions.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
You can see what I currently have at

As you can see I already have the oncurrent event in use.

Maybe I am limiting my options saying I want a command button.

I'm sure I do want a way for the user to choose a file and to place its path in the text field of the form.
 
In case anybody is interested in an easier way for the relative path:

stpath = CurrentProject.Path
stpath = stpath & "\[your folder name]\[you file name]"
Me![Picture image].Picture = stpath

Thank you scriverb for this valuable post! It works great
 
TRW: First of all, thanks for the kind words.

With a multi-user database system using the FE and BE database design, the picture images would be stored on the server and not the users PC. With the path to the CurrentProject being the path to the location of the FE database this would not be useful. However, we could look for a linked table and pickup the path to the server location of that database housing the table. If the folder with the images was stored within that location then there would be no need to store anything in the FE relative to the image location. Another way of doing it.



[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
This will require the use of the ActiveX control(Microsoft Common Dialog Control - comdlg32.ocx ). After you create the control on your form and it should be established with the visible property set to NO, then put the following behind a command button.

Code:
CommonDialog1.ShowOpen
MsgBox "Filename: " & _
  CommonDialog1.FileTitle
MsgBox "Path: " & Left$(CommonDialog1.FileName, _
  Len(CommonDialog1.FileName) - Len(CommonDialog1.FileTitle))
MsgBox "Path: " & CommonDialog1.FileName
Me![textcontrolname] = CommonDialog1.FileName

The two MsgBox's are just to demonstrate that you are picking the path and field name.

Let me know how this works in your database. Sorry about the delay in getting back to you as I had meetings most of the day.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Thanks for the reply, on another forum it was suggested that I try it.

I did and got an error message that the OLE server is not registered and to re-install.

I got the most current MDAC from Microsoft, and am current on all of my Windows updates.

I get the same result on three different pc's. Two with XP on them, one with 2000.

I was flummoxed before, but now I'm really in a hole!


j

Just knowlegeable enough to cause problems.
 
Oh, and I *DO NOT* have any Norton Anti-Virus running. I use CA's EZAntivirus.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top