Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    james28 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    92

    Master and Detail Split Form View


    Hello all!
    I am a bit confused about how to proceed and I was hoping that someone could give me an idea of how to proceed. I have a single table full of data. I realize that this is not the proper way to do it, but due to other constraints, I can not split it up. The table is basically a list of students. Each student has several statistics associated with them, like age, name, ID, and teacher. I have users that I want to be able to edit records, but I want to give them a nice UI to do it in.


    What I need is some form of UI/form that will allow a user to display all records in the database in two parts. The first part, would be a condensed list (maybe just student name and ID) in a format that is not able to be edited. When a student is clicked on, another section of the page loads the full record, but not in the standard table view. I would like for it to be a form that can be design and formatted as I need. The full record needs to be editable.

    Is there a certain type of form that will allow me to establish this sort of view?

    Thank you for any guidance that you can provide!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Posts
    528

  4. #4
    james28 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    92
    Thank you very much for the guidance. That seems to be very close to what I am trying to do. I have done some initial testing and I have noticed something that I can not seem to change. I want users to have a submit button of some sort to commit any changes that they make in the top part of the form to the database. Is this possible?


    Thank you all again!

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Data entry/edit is committed to table when moving to another record, close form, or run code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    james28 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    92
    One thing to add/clarify,

    I can add a "save record" button no problem. When pressed, it immediately saves the changes that have been made. The issue is that, even with the button present, if you make a change, do not click "save record", and close the form, the change is committed. Is there some way to make it so that the only way a change is saved is with the "save record" button?


    Thank you!

  7. #7
    james28 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    92
    Quote Originally Posted by June7 View Post
    Data entry/edit is committed to table when moving to another record, close form, or run code.
    June, thank you for the reply. You responded as I was typing my additional reply. Is there a way to disable all of the things that you said, except my "save record" button?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    I always disable the X close button and provide users with custom buttons to close form. I have "Cancel/Quit" and "Save/Quit" button options. If Cancel/Quit then 'undo edits' code runs. However, I have only been able to get this to work by using Sendkeys method with {ESC}{ESC}.

    Another possibility may be to have a variable declared in form code module header: booSave

    Boolean variable default is False. If user clicks "Save", code in the button Click event would set the variable True. Code in form BeforeUpdate event would check this variable and if True allow data to commit and reset variable to False, otherwise abort.

    However, I find that this is more complicated in form/subform structure. I have one arrangement with 4 subforms and changing focus between subforms commits records. My "Cancel/Quit" is then ineffective.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    james28 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    92
    I was able to dig up this bit of code.
    Dim saveAns As Integer

    saveAns = MsgBox("Do you want to exit without saving changes?", vbYesNo)

    If saveAns = vbYes Then
    Me.Undo
    Else
    Cancel = TRUE
    End If
    I added it to the before update of the form.


    It only partially works as needed though. When closing the form, with a change that has not been saved, it gives the pop up. If I say yes, the form closes and no change is saved. If I hit no, it does not close and takes me back to the form. The change is not saved at this point.

    The "save record" button that I created does not function any longer. It does the same thing as if I tried to close the form, when I press it.



    Any idea how to fix this? Thank you!

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    I tried your code and when clicking no I get "... can't save record ... do you want to close the database object anyway ..."

    Did you review my previous post?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    james28 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    92
    June,

    Thank you for the reply. I did not see it prior to my post. Could you please share the code that you use for both of your example buttons?



    Also, I was not able to reproduce the error that you get from my code. I have included it again, incase I missed part of it.


    Thank you again!

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim saveAns As Integer
        
        saveAns = MsgBox("Do you want to exit without saving changes?", vbYesNo)
        
        If saveAns = vbYes Then
            Me.Undo
        Else
            Cancel = True
        End If
    End Sub

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    All I did was copy/paste your code into my form code module. I make data edit then click the X close button which is still active for this form. First the MsgBox runs and after click No, the second message opens.

    Here is my Cancel button code:

    Private Sub btnCancel_Click()
    'using SendKeys because could not get Undo to work.
    SendKeys "{ESC}", True
    SendKeys "{ESC}", True
    DoCmd.Close acForm, Me.Name, acSaveNo
    End Sub

    Save button just closes the form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The code

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim saveAns As Integer
        
        saveAns = MsgBox("Do you want to exit without saving changes?", vbYesNo)
        
        If saveAns = vbYes Then
            Me.Undo
        Else
            Cancel = True
        End If
    End Sub


    prevents the Update from happening, regardless of whether you click on Yes or No! Drop the Else Clause:

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    
    Dim saveAns As Integer
        
        saveAns = MsgBox("Do you want to exit without saving changes?", vbYesNo)
        
        If saveAns = vbYes Then
            Me.Undo
        End If
    
    End Sub

    Linq ;0)>

  14. #14
    james28 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    92
    June,
    Thank you for the reply. That is very odd that it acts that way for you. I tried your code, but I now see what you were getting at before. With this setup, when a user changes records, it saves the changes.




    Missinglinq,

    Thank you for finding the issue with the code. That seems to have made it run as expected when the form is closed. The problem now is when ever I use a "save record" button, the same message pops up. Do you know of any way to suppress the message for the save record button?


    Thank you both!

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Review post 8.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Master\Detail Only Show Last Detail Record
    By jamies in forum Queries
    Replies: 2
    Last Post: 04-14-2014, 01:25 PM
  2. Replies: 6
    Last Post: 11-18-2012, 12:54 PM
  3. Master/detail form problem....
    By dkperez in forum Forms
    Replies: 5
    Last Post: 04-01-2011, 04:28 PM
  4. Master Detail Web Form - Access 2010.
    By Robeen in forum Forms
    Replies: 2
    Last Post: 03-21-2011, 02:34 PM
  5. Enable button in the master form when clicking in the detail
    By DistillingAccess in forum Programming
    Replies: 8
    Last Post: 08-03-2010, 10:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums