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

cannot get picture to display on the form 1

Status
Not open for further replies.

Sheena2

Programmer
Apr 18, 2008
9
CA
When I put the following code I cannot get the picture to be displayed . Please let me know what I am doing wrong.

Private Sub Report_Open(Cancel As Integer)
Dim GetPathPart As String
GetPathPart = "S:\FDRCM\WorkShopMaps"
On Error GoTo err_Report_Open

If Not Me!txtPicture = "" Or Not IsNull(Me!txtPicture) Then
Me!Picture.Picture = GetPathPart & Me!txtPicture
Else
Me!Picture.Picture = ""
End If

exit_Report_Open:
Exit Sub

err_Report_Open:
MsgBox Err.Description
Resume exit_Report_Open
End Sub
 
Assuming GetPathPart & Me!txtPicture is a valid path, have you had a look at trying:
Code:
Me!Picture.Picture = LoadPicture(GetPathPart & Me!txtPicture)
Hope this helps


HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
I'd try to move the code from the Open to the Load event procedure.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You may find it useful to test for a valid path with the following function.

Code:
'PARAMETERS: fully qualified path
'RETURNS: true if path is valid
'Created by Charlotte Foust
Public Function pfValidPath(strPathName) As Boolean
    pfValidPath = Len(Dir$(strPathName, vbNormal)) > 0
End Function

Is txtPicture providing the necessary file name and type? Have you used debug.print to see what you are actually passing as a path?

Cheers
Bill
 
How are ya Sheena2 . . .

There's a missing [blue]back slash[/blue] in [red]GetPathPart[/red]:
Code:
[blue]   GetPathPart = "S:\FDRCM\WorkShopMaps[red][b]\[/b][/red]"[/blue]
If the [blue]back slash[/blue] is included in [blue]Me!txtPicture[/blue] then no problemo, however I don't believe your saving filenames this way.

Do check this out!

[blue]Your Thoughts? . . . [/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
When I put in the following code the picture does not change and it gives me the following message:cnnot ifnd the field txtpicture referred to in your expression. My pictures are in jpg format. thanks
Please help.

Private Sub Report_Open(Cancel As Integer)
Dim GetPathPart As String
GetPathPart = "S:\FDRCM\WorkShopMaps\"
On Error GoTo err_Report_Open

If Not Me!txtPicture = "" Or Not IsNull(Me!txtPicture) Then
Me!Picture.Picture = LoadPicture(GetPathPart & Me!txtPicture)
Else
Me!Picture.Picture = ""
End If

exit_Report_Open:
Exit Sub

err_Report_Open:
MsgBox Err.Description
Resume exit_Report_Open
End Sub
 
Sheena2 . . .

The error is saying [blue]txtPicture[/blue] doesn't exist on the form. Is this correct?

Also, post an example of what should be in [blue]txtPicture[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Again, it's not advisable to play with controls in the Open event procedure as the form in not yet loaded.
Thus I suggest to use the Load event or, if the form is bound, the Current event.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks Aceman1

I am trying to show directions to a place using a map. Sorry cannot attach the file as it won't let me k=do that. thnaks for all your help
 
Howdy [blue]PHV[/blue] . . .

Your 1st post was duly noted. I'm currently trying to find out if [blue]txtPicture[/blue] which holds the filename actually exist, and which section the Graphics Object resides in. Its a [blue]report[/blue], and yes, code will have to be moved to [blue]On format[/blue] or [blue]On Print[/blue].


Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Sheena2 . . .

Since you didn't answer my question, I'll just have to do my best to get closer to finalizing here.

Your caption for this thread is titled:
ThisThreadCaption said:
[blue]cannot get picture to display on the [purple]form[/purple][/blue]
And although you keep refering to form, the initial code you provided
Code:
[blue]Private Sub [purple][b]Report[/b][/purple]_Open(Cancel As Integer)[/blue]
shows [purple]were actually dealing with a report![/purple]

Now . . . since you didn't answer my question:
TheAceMan1 said:
[blue]The error is saying txtPicture doesn't exist on the form. [purple]Is this correct?[/purple][/blue]
I'd like to resolve this all stopping issue.

Question: If [blue]txtPicture[/blue] doesn't reside on the report, does it reside on the calling form? . . . or just where is it suppose to be.

And for the record, [blue]txtPicture[/blue] should contain the file name in question, like, [blue]Map1.jpg[/blue]

Now, initial correction will be:
[ol][li]Cut the code from the reports [blue]On Open[/blue] event.[/li]
[li]In the [blue]On Print[/blue] event of the [blue]section[/blue] where your [blue]image object resides[/blue], paste the code.[/li][/ol]
When your done, it still may not work as were still trying to find where the infamous [blue]txtPicture[/blue] resides!

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Thanks Aceman1 the changes were made as you advised and it works now. have a nice day
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top