Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / April 2008

Tip: Looking for answers? Try searching our database.

Linked image and error display simultaneously

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shelter@jointanimalservices.org - 18 Apr 2008 19:20 GMT
I am running Access 2003.

I have linked images to display on a form. The image path is stored in
tblPersons.Photo. The form has a text box "txt.Photo" which displays
the contents of tblPersons.Photo and cmdAdd and cmdDelete buttons to
allow the user to browse to and add a photo or delete a photo. There
is a hidden lblMsg that displays "Click Add-# to create a photo for
this volunteer" when no photo has been entered. (I have used Add-1,
Add-2 and Add-3 in the text to differentiate between them in different
parts of the code. Once it's working, I will delete the numerical
references.)

My problem is: When a user clicks the Add button and adds a photo, the
photo displays correctly. However, once the user moves to a different
record, then returns to the record, the photo AND the text in lblMsg
are displayed simultaneously (Click Add-3...). I cannot figure out why
this is occuring and appreciate any help. I am not an advanced coder,
and stepping through this didn't reveal anything to my uneducated eye.

Thank you,
DJohnson

The code is modified from John Viescas' example:

Private Sub Form_Current()
' Load the current image, if any, when moving to new row
Dim strPath As String
   ' If on new record,
   If Me.NewRecord Then
       ' Then set the message
       Me.lblMsg.Caption = "Click Add-2 to create a photo for this
volunteer."
       ' Make it visible
       Me.lblMsg.Visible = True
       ' .. and hide the image frame
       Me.imgVolunteer.Visible = False
       Exit Sub
   End If

   ' Try to load image - set error trap
   On Error Resume Next
   ' If nothing in the photo text,
   If Len(Trim(Nz(Me.Photo))) = 0 Then
       ' Then set the message
       Me.lblMsg.Caption = "Click Add-3 to create a photo for this
volunteer."
       ' Make it visible
       Me.lblMsg.Visible = True
       ' .. and hide the image frame
       Me.imgVolunteer.Visible = False
   Else
       strPath = Me.Photo
       ' Check for characters that indicate a full path
       If (InStr(strPath, ":") = 0) And (InStr(strPath, "\\") = 0)
Then
           ' Just a file name, so add the current path
           strPath = CurrentProject.Path & "\" & strPath
       End If
       ' Attempt to assign the file name
       Me.imgVolunteer.Picture = strPath
       ' If got an error,
       If Err <> 0 Then
           ' Then set the message
           Me.lblMsg.Caption = "Photo not found.  Click Add to
correct."
           ' Make it visible
           Me.lblMsg.Visible = True
           ' .. and hide the image frame
           Me.imgVolunteer.Visible = False
       Else
           ' Resize the picture
           Me.imgVolunteer.Width = 2160
           ' Reveal the picture
           Me.imgVolunteer.Visible = True
           ' And set the form palette so the picture displays
correctly
           Me.PaintPalette = Me.imgVolunteer.ObjectPalette
       End If
   End If

End Sub
Carl Rapson - 21 Apr 2008 16:23 GMT
>I am running Access 2003.
>
[quoted text clipped - 77 lines]
>
> End Sub

I see where you're making lblMsg visible, but not where you're making it
invisible. If you move to a record with no picture, the label will be made
visible; if you then move to a record with a picture, the label will still
be visible. Try adding the line

Me.lblMsg.Visible = False

within your final Else...End If block (where you resize the picture and make
it visible).

Carl Rapson
shelter@jointanimalservices.org - 21 Apr 2008 16:47 GMT
On Apr 21, 8:23 am, "Carl Rapson" <mr.mxyzp...@newsgroups.nospam>
wrote:
> <shel...@jointanimalservices.org> wrote in message
>
[quoted text clipped - 95 lines]
>
> - Show quoted text -

Thank you so much--worked like a charm!

DJohnson
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.