Senin, 28 Agustus 2017

Re: [MS_AccessPros] Saving a photo.

 

That did it thank you so much!!!!



With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Valar Dohaeris"








From: John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
To: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com>
Sent: ‎Monday‎, ‎August‎ ‎28‎, ‎2017‎ ‎10‎:‎48‎:‎52‎ ‎AM
Subject: Re: [MS_AccessPros] Saving a photo.

 

Art-


Your code should be updating only the "current" row.  The only reason you would see something repeated is if the values are repeated or you've set the value of an unbound control.  If there's an Image control on sfrmMetTestTrackingNoteList, it should show the photo for the current row currently as long as the Control Source is set to the Photo field.

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Aug 28, 2017, at 5:04 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



Yes I do. Its just tied to the table tblMetTestTrackingNotes no query.


With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Valar Dohaeris"








From: John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: ‎Monday‎, ‎August‎ ‎28‎, ‎2017‎ ‎09‎:‎16‎:‎49‎ ‎AM
Subject: Re: [MS_AccessPros] Saving a photo.

Do you mean sfrmMetTestTrackingNoteList in the document you uploaded earlier?


What's the Record Source of frmMTTNoteDetails and of sfrmMetTestTrackingNoteList??  If a query, what's the SQL?

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Aug 28, 2017, at 4:03 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



OK. I open Note Details form by itself and made txtPhoto visible. It works correctly now. Saves, and everything. Now the issue is that when the Note Details closes and the focus shifts back to the sfrmMTTNoteList the first photo in the first record is displayed in all the records.


With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Valar Dohaeris"








From: John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: ‎Sunday‎, ‎August‎ ‎27‎, ‎2017‎ ‎11‎:‎18‎:‎05‎ ‎AM
Subject: Re: [MS_AccessPros] Saving a photo.

Art-


Did you add a Photo control to the forms as I suggested?  Then you could see whether the file path is being inserted correctly.  It may be updating, but the Image control can't find the file.

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Aug 27, 2017, at 6:10 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



John,
The sequence as you describe is correct. And the note record is being saved correctly. Could you take a minute and review the add code and see why the path is not being written to the table. Everything else appears to be working correctly except for that.



With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Valar Dohaeris"








From: John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: ‎Sunday‎, ‎August‎ ‎27‎, ‎2017‎ ‎05‎:‎11‎:‎36‎ ‎AM
Subject: Re: [MS_AccessPros] Saving a photo.

OK, I can see the pictures, but I still don't understand the sequence.  Does clicking New Test on frmUnitDetails open frmMTTDetails?  And does clicking New Note on the Photos/Notes tab of frmMTTDetails open frmMTTNoteDetails?  Does clicking the pencil icon next to a record on the Photos/Notes tables of frmMTTDetails also open frmMTTNoteDetals but for the current record?


You say that the picture path isn't getting saved after you click Add Picture and select a file.  Is the Note itself saved?  If not, then there's a problem providing the linking info between frmMTTDetails and frmMTTNoteDetails.  If the Note does get saved, you somehow must not be correctly updating the underlying text column that points to the file.  You could temporarily add that text column (Photo?) to both the Photo/Notes tab of frmMTTDetails and frmMTTNoteDetails to actually see the text you think you're saving.  That might help you figure it out.  Perhaps truncating the file path if the photo is the path of the current database isn't working as you expect.  You might need to store the entire path to be sure you get the photo loaded.

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Aug 26, 2017, at 10:49 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



John, I have uploaded a Word document that contains snapshot of the screens in question to help clarify what is happening. It is in Needs Assistance


With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Valar Dohaeris"








From: John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: ‎Saturday‎, ‎August‎ ‎26‎, ‎2017‎ ‎01‎:‎36‎:‎52‎ ‎PM
Subject: Re: [MS_AccessPros] Saving a photo.

OK.  I assume your "main" form is editing tblMethTestTracking and frmMTTNoteDetails is editing the other table.  You also mentioned a subform - what is that editing?  If both the subform and frmMTTNoteDetails are editing tblMethTestTrackingNotes, then you have to be careful to make sure the record is saved in the subform before you call frmMTTNoteDetails AND filter on both the MTTID and the MTTNoteID to ensure you're editing the same record.  If MTTNoteID is the PKey of tblMethTestTrackingNotes, then that's what you should be filtering on, not MTTID.


John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Aug 26, 2017, at 8:02 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



Table: tblMethTestTracking                                                                                                       Page: 1

  Columns

            Name                                                                 Type                               Size

            MTTID                                                                Long Integer                                        4

            UnitID                                                                Long Integer                                        4
            MTTVacantUnit                                                     Yes/No                                               1
            MTTIntentToVacate                                                Yes/No                                               1
            MTTNameChange                                                   Yes/No                                               1
            MTTLegal                                                            Yes/No                                               1
            MTTRequest                                                         Yes/No                                               1
            MTTOther                                                            Yes/No                                               1
            MTTOtherDesc                                                      Short Text                                         50
            MTTInitialMethChek                                                Yes/No                                               1
            MTTOtherCleaning                                                  Yes/No                                               1
            MTTOtherCleaningDesc                                            Short Text                                         50
            CreateDate                                                          Date With Time                                     8
            CreatedBy                                                           Short Text                                         50
            ModifiedDate                                                        Date With Time                                     8
            ModifiedBy                                                           Short Text                                         50
            MTTTester1ID                                                       Long Integer                                        4
            MTTTester2ID                                                       Long Integer                                        4
            MTTDate                                                             Date With Time                                     8

Table: tblMethTestTrackingNotes                                                                                                Page: 2

  Columns

            Name                                                                 Type                               Size

            MTTNoteID                                                          Long Integer                                        4

            MTTID                                                                Long Integer                                        4
            NoteDate                                                            Date With Time                                     8
            NoteTypeID                                                         Long Integer                                        4
            NoteSubject                                                         Short Text                                         50
            NoteDescription                                                     Long Text                                            -
            PhotoOld                                                             Long Text                                            -
            EmployeeID                                                         Long Integer                                        4
            LogTime                                                             Date With Time                                     8
            Photo                                                                 Short Text                                         50



They are related by the MTTD field.

With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Valar Dohaeris"








From: John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: ‎Saturday‎, ‎August‎ ‎26‎, ‎2017‎ ‎12‎:‎54‎:‎39‎ ‎PM
Subject: Re: [MS_AccessPros] Saving a photo.

Art-


Is "Notes" a separate table?  Related to the main one?  What's the table design?


John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Aug 26, 2017, at 7:34 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



John,

OK I did that. The adds and edit work for everything but the photo. The photo adds correctly to the note but does not retain it it for the editing. I loke into my note table and I discovered its not saving the path to the photo field in the notes table.


With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Valar Dohaeris"








From: John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: ‎Saturday‎, ‎August‎ ‎26‎, ‎2017‎ ‎12‎:‎21‎:‎07‎ ‎PM
Subject: Re: [MS_AccessPros] Saving a photo.

Actually, it would be better if you were to force the save of any new record on the calling form *before* loading the form to add a photo.  If you do that, the filter on the form (you need to add one in cmdNewNote_Click) should do the trick.  You'll be "adding" a photo to an existing record.


John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Aug 26, 2017, at 6:56 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



Sorry. The load statement is there:


Private Sub Form_Load()
If Me.NewRecord Then
     Me.MTTID = Me.OpenArgs


End If
End Sub


It is passing the MTTID value to the new record. I can add and edit the record. It has all the information except it doesn't retain the photo.

I don unertand what you are saying about the NewNote condition I will move that button out to the Details tab. But even when I edit the record that exists, the photo is there and I have to go back and add it each time.

With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Valar Dohaeris"








From: John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: ‎Saturday‎, ‎August‎ ‎26‎, ‎2017‎ ‎11‎:‎21‎:‎21‎ ‎AM
Subject: Re: [MS_AccessPros] Saving a photo.

Art-


You don't show the Form_Open code that should be grabbing Me.OpenArgs and setting MTTID.  Also, if the user clicks cmdNewNote *before* a new record in the subform is saved, the record won't be there yet to edit and add the photo.

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Aug 26, 2017, at 5:37 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



Private Sub cmdNewNote_Click()
On Error GoTo Err_cmdNewNote_Click

    Dim stDocName As String
    Dim intArgs
    
    Dim stLinkCriteria As String
    intArgs = Forms![frmMTTDetails].MTTID
    
    stDocName = "frmMTTNoteDetails"
    
    If Not IsNull(intArgs) Then
        DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd, acDialog, intArgs
    Else
        MsgBox "You must fill in all values"
    End If
    Me.Requery
    
Exit_cmdNewNote_Click:
  Exit Sub
Err_cmdNewNote_Click:
  
   'ErrorHandler "sfrmRoofNoteList", "cmdAddNote_Click", Err.Number, Err.Description
    Resume Exit_cmdNewNote_Click
End Sub

John,

The record source is tblMethTestTracking. Yes I believe I am. I should have specified. frmMTTDetails contains a subform called sfrmMethTestTrackingNoteList which are link together by MTTID. The user then click the cmdEdit button (code below) the specific record they want to open:


Private Sub cmdEdit_Click()
  ViewMTTNote
End Sub

Private Sub ViewMTTNote()

     Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "frmMTTNoteDetails"
    stLinkCriteria = "[MTTNoteID]=" & Me![MTTNoteID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Forms.frmMTTNoteDetails.AllowAdditions = False


End Sub

When a new note is created, the MTTID is passed to the frmMTTNoteDetails via a OpenArg:



With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Valar Dohaeris"








From: John Viescas JohnV@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: ‎Friday‎, ‎August‎ ‎25‎, ‎2017‎ ‎03‎:‎11‎:‎28‎ ‎PM
Subject: Re: [MS_AccessPros] Saving a photo

Art-


What is the Record Source of frmMTTDetails, and are you synchronizing that form to position on the record you selected with Edit on the other form?

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Aug 25, 2017, at 9:52 PM, dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



I have a from called frmMTTList that is a continuous form. AS the records are displayed on this form I have include and Edit button that display the Details on a from called frmMTTDetails. I am storing the location of an image on this screen. Now I found a sample database on this site that I have adapted. Code as follows:


Private Sub cmdAdd_Click()
 ' User asked to add a new photo
Dim strPath As String

    ' If you want to use the Office FileDialog object,
    ' comment out the following code and remove the
    ' comments from the block below
' ***** Begin ComDlg code
    ' Establish a new ComDlg object
    With New ComDlg
        ' Don't allow multiple files
        .AllowMultiSelect = False
        ' Set the title of the dialog
        .DialogTitle = "Locate MTT picture File"
        ' Set the default directory
        .Directory = CurrentProject.Path & "\Pictures\"
        ' .. and file extension
        .Extension = "bmp"
        ' .. but show all graphics files just in case
        .Filter = "Image Files (.bmp, .jpg, .gif, .pdf)|*.bmp;*.jpg;*.gif;*.pdf"
        ' Tell the common dialog that the file and path must exist
        .ExistFlags = FileMustExist + PathMustExist
        If .ShowOpen Then
            strPath = .FileName
        Else
            Exit Sub
        End If
    End With
' ***** End ComDlg code
    


        ' Set an error trap
        On Error Resume Next
        ' Set the image
        Me.imgMTT.Picture = strPath
        ' Make sure that "took" OK
        If Err = 0 Then
            ' Got a good file selection ...
            ' See if the photo is in a subpath of this project
            If Left(strPath, Len(CurrentProject.Path)) = CurrentProject.Path Then
                ' Strip it off and store a relative path
                strPath = Mid(strPath, Len(CurrentProject.Path) + 2)
            End If
            ' Set the path in the record
            Me.txtPhoto = strPath
            ' Hide the message
            Me.lblMsg.Visible = False
            ' and reveal the new photo
            Me.imgMTT.Visible = True
        Else
            ' OOOps.
            ' Clear photo
            Me.txtPhoto = Null
            ' Hide the frame
            Me.imgMTT.Visible = False
            ' Clear the image
            Me.imgMTT.Picture = ""
            ' Set the message
            Me.lblMsg.Caption = "Failed to load the picture you selected.  Click Add to try again."
            ' Make it visible
            Me.lblMsg.Visible = True
        End If
    ' Put focus in a safe place
    Me.txtNoteDate.SetFocus


End Sub

Private Sub cmdDelete_Click()
' User asked to remove the picture

    ' Clear photo
    Me.txtPhoto = Null
    ' Hide the frame
    Me.imgMTT.Visible = False
    ' Clear the image
    Me.imgMTT.Picture = ""
    ' Set the message
    Me.lblMsg.Caption = "Click Add to create a photo for this MTT."
    ' Make it visible
    Me.lblMsg.Visible = True
    ' Put focus in a safe place
    Me.txtNoteDate.SetFocus
End Sub

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 to create a photo for this MTT."
        ' Make it visible
        Me.lblMsg.Visible = True
        ' .. and hide the image frame
        Me.imgMTT.Visible = False
        Exit Sub
    End If
    
    ' Try to load image - set error trap
    On Error Resume Next
    ' If nothing in the photo text,
    If IsNothing(Me.Photo) Then
        ' Then set the message
        Me.lblMsg.Caption = "Click Add to create a photo for this MTT."
        ' Make it visible
        Me.lblMsg.Visible = True
        ' .. and hide the image frame
        Me.imgMTT.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.imgMTT.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.imgMTT.Visible = False
        Else
            ' Reveal the picture
            Me.imgMTT.Visible = True
            ' And set the form palette so the picture displays correctly
            Me.PaintPalette = Me.imgMTT.ObjectPalette
        End If
    End If
    
End Sub


Private Function SaveIt() As Integer
Dim lngErr As Long, strError As String

    ' Common Save routine called from cmdSave and a couple of other places
    
    ' Default: We expect this to work
    SaveIt = True
    ' No need to do anything if the form isn't "dirty"
    If (Me.Dirty = True) Then
        ' OK, gonna try to save - set error trap
        On Error GoTo Save_Error
        Me.Dirty = False  ' Force a save by resetting Dirty
    End If
    
Save_Exit:
    Exit Function
    
Save_Error:
    ' Got here if the save failed.  Handle most common errors
    '  (Some may be handled by Form_Error instead)
    SaveIt = False  ' Indicate save failed
    ' Try to analyze the error
    Select Case Err
        Case errCancel, errCancel2, errPropNotFound ' Cancel - ignore
            Resume Save_Exit
        Case errDuplicate  ' Duplicate row - custom error message
            MsgBox "You're trying to add a record that already exists.  " & _
                "Enter a new  Note or click Cancel.", vbCritical, gstrAppTitle
        Case errInvalid, errInputMask
            ' Invalid data - custom error and log
            MsgBox "You have entered an invalid value. ", vbCritical, gstrAppTitle
            ErrorLog Me.Name & "_Save", Err, Error
        ' Field validation, Table validation, Custom Validation, End of Search, Spelling Check
        Case errValidation, errTableValidate, errCustomValidate, errSearchEnd, errSpellCheck
            ' Display the error
            ' All validation rules in the tables have custom error messages.
            MsgBox Error, vbCritical, gstrAppTitle
        Case Else
            ' Dunno - log and let error display
            ' Save the error code values because ErrorLog may get additional errors
            lngErr = Err
            strError = Error
            ErrorLog Me.Name & "_Save", lngErr, strError
            MsgBox "Error attempting to save: " & lngErr & " " & strError & Chr$(13) & Chr$(10) & "Try again or click Cancel to close without saving.", 48, gstrAppTitle
    End Select
    Resume Save_Exit

End Function



Now my issue It Adds the photo when I click the AddPhoto button but when I save and close the detail form and then once again in the List form I click the edit button and it is retaining everything but the image. I am not sure where I went bad....


Thank you,


Art Lorenzini    

Sioux Falls, SF




























__._,_.___

Posted by: Art Lorenzini <dbalorenzini@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (20)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar