Sabtu, 26 Agustus 2017

Re: [MS_AccessPros] Saving a photo.

 

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>
To: MS_Access_Professionals@yahoogroups.com <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 (9)

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