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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a link to a file stored in o

Status
Not open for further replies.

Aubs010

Technical User
Apr 4, 2003
306
GB
I have a link to a file stored in one column of a record.

Site Logo - M:\Email\AB\Other\Logos\Logo.gif

Right, I have it on a form, that when I type a file locaiton into a text box, and move away from the textbox, it updates the logo on the form.

Now, I need to have the same principle on a report.

say:
Code:
 __________________
|      TEXT        |
|      ....        |
|      ....        |
|   -----------    |
|  |           |   |
|  |           |   |
|  |   LOGO    |   |
|  |           |   |
|   -----------    |
|__________________|
but I can't get it to load the image when using the file location from SiteDetails.[Site Logo]

Any suggestions would be greatly appreciated :)
Aubs
 
Hi,
In a report, you would want to follow these steps:
1) Create the image control in the detail section to be big enough to display the real picture.
2) Use the OnFormat of the detail section to load the code, exactly the same as we did in the Forms forum. Presuming your reports' image control is called "imgEmployeePicture", here is the code that should work:
imgEmployeePicture.Picture = ("\pics\" & [txtEmployeePicLocation])

Sometimes this is not enough. You may have to use the LoadPicture function. Here is what that code might look like:
imgEmployeePicture.Picture = LoadPicture(("\pics\" & [txtEmployeePicLocation]) HTH, [pc2]
Randy Smith
California Teachers Association
 
OOOPs!!
There should only be one parentheses after the LoadPicture function. It should look like this:
imgEmployeePicture.Picture = LoadPicture("\pics\" & [txtEmployeePicLocation]) HTH, [pc2]
Randy Smith
California Teachers Association
 
Randy,

Thanks for your posts.

I have tried it in three ways!
[tt]
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'SLP.Picture = LoadPicture("\pics\" & [Site Logo])
'SLP.Picture = ("\pics\" & [Site Logo])
SLP.Picture = [Site Logo]
End Sub
[/tt]

As you can see, I 'Commented one out while I tried the other.

All that happens, is when I press the "View" button to view the report, it jumps straight back to the design view (it flashes once - as if it tried to view it).

Any suggestions?

It's getting really frustrating!!!!

I also followed an example from the help file:

------------------------------
In a form or report, add an image control that is bound to a text field containing the paths to the pictures
[ol][li]If the field list isn't displayed, click Field List on the toolbar. [/li]
[li]From the field list, drag the field that contains the locations of the pictures to the form or report.[/li]
[li]In the toolbox, click the Image tool.[/li]
[li]On the form or report, click where you want to place the object. [/li]
[li]In the Insert Picture dialog box, specify the path to any picture, and then click OK. For example, you can type the path to the picture for the first record. [/li]
[li]Double-click the form selector (form selector: The box where the rulers meet, in the upper-left corner of a form in Design view. Use the box to perform form-level operations, such as selecting the form.) or the report selector (report selector: The box where the rulers meet in the upper-left corner of a report in Design view. Use the box to perform report-level operations, such as selecting the report.) to open the property sheet. [/li]
[li]Click the Build button next to the OnCurrent property box, and then click Code Builder in the Choose Builder dialog box. [/li]
[li]Create the following event procedure. Substitute the name of the image control on your form or report for ImageControlName and the name of the control containing the path for ImagePath. [/li]

[tt]Private Sub Form_Current()

On Error Resume Next

Me![ImageControlName].Picture = Me![ImagePath]

End Sub[/tt]

Note that if you are adding the event procedure in a report, the first line of the procedure will be the following:

[tt]Private Sub Report_Current()[/tt]

[li]On the File menu in the Visual Basic Editor, click Close and return to Microsoft Access. [/li]
[li]Click the control that is bound to the text field containing the location of the pictures, and then click Properties on the toolbar to open the property sheet.. [/li]
[li]Click the Build button next to the AfterUpdate property box, click Code Builder in the Choose Builder dialog box, and create the following event procedure. Substitute the name of the image control on your form or report for ImageControlName and the name of the control containing the path for ImagePath. [/li]

[tt]Private Sub ImagePath_AfterUpdate()

On Error Resume Next

Me![ImageControlName].Picture = Me![ImagePath]

End Sub[/tt]

This event procedure enables you to add or change a picture location in Form view.

[li]On the File menu in the Visual Basic Editor, click Close and return to Microsoft Access. [/li]
[/ol]
Note To see an example of an image control that is bound to a field containing the locations of pictures, open the Employees form in the Northwind sample database.
------------------------------

But this didn't work. It says it's for forms and reports, but it only works on forms! There is no Items 6 & 7 above.

Pleeeeaaasssseee Help! It really is doing my head in!
Aubs
 
Right, I got it to work!!!

I followed the example in the help file, but substituted the part (7) above for the OnFormat as Randy suggested! (Thanks Randy!!) and used:
Me![Report-SiteLogo].Picture = Me![Site Logo]

Thanks for all your help & inspiration, much appreciated :)


Aubs.
Aubs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top