Results 1 to 10 of 10
  1. #1
    NightWalker's Avatar
    NightWalker is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    Midwest USA
    Posts
    253

    Record control on multiple forms


    I have multiple forms that I want to have an identical set of record controls like next, new, and previous records, submit record, and exit form. Is there a way to have something like a subform that has all the controls on it instead of making the same buttons on every individual form? If this is possible would the majority of the code go in a module? If there is a better or easier way to do this please point me in the right direction. This is just a wild thought I had. Thank you for your help in advance. --Walker

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    The following link may be of interest: https://www.alvechurchdata.co.uk/hin...ccnavform.html
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    NightWalker's Avatar
    NightWalker is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    Midwest USA
    Posts
    253
    Bob,
    That is exactly what i was looking for. I googled to find it and didn't get any results that were even close to that. Thank you very much for the link.
    --Walker

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Glad we could help
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    I saw your post yesterday which prompted me to tinker with building a custom class and form similiar to the one Bob gave you the link to.
    It sounded like a good candidate for a custom class, to make an easily portable form.
    This was a learning exercise for me me but since I have it working I figured I post it.


    1. Just import the form sfrmNavBar and the class module.
    2. Drop the subform into your main form.
    3. Add 2 lines of code to your main form - 1 line to instantiate the class and 1 line to initiate it. ( see the code in Form1)


    You can change the button colors, size and captions, etc. Just dont change the button names.
    There is no code in the form sfrmNavBar. Its all in the class.
    There are optional arguements to cycle through the form recordset instead of stopping at .EOF or .BOF and to use autorepeat key presses.
    Attached Files Attached Files

  6. #6
    NightWalker's Avatar
    NightWalker is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    Midwest USA
    Posts
    253
    Moke,

    Thank you very much for playing with this. I am going to try to understand your code today. I think some of what you have is a little over my head but I will see what i can figure out.

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    NightWalker

    The attached db has a form which could be imported to your db and then used as a sub form on any of your forms.
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    NightWalker's Avatar
    NightWalker is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    Midwest USA
    Posts
    253
    @ Moke,

    I looked at your code. Could you explain the flow of the code a little. I understand the on click events. I am not understanding all the get and set property code at the bottom of the code and I dont understand the withevents at the top. I really like it and am trying to completely understand it completely.

    @Bob

    Thank you for your DB. I hope you dont mind but i took some of the code from it and used it in mine.

  9. #9
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Quote Originally Posted by NightWalker View Post
    @ Moke,

    I looked at your code. Could you explain the flow of the code a little. I understand the on click events. I am not understanding all the get and set property code at the bottom of the code and I dont understand the withevents at the top. I really like it and am trying to completely understand it completely.
    Not sure I can explain it as I'm still learning alot about them. Its a custom class. The idea is to be able to just drop it into a project and have it work with very little code. Do all the coding up front and then re-use it with very little coding. Its probably a little overkill in this example but it's fun putting it together. As you can see theres no code in the subform. The objects that have withevents are the subform and all its buttons. The withevents just tells the code to listen for events from those objects and passes them to the code to handle them.

    I did find one logic error after I posted. Needed to add "Or Me.TheParentForm.NewRecord Then" as shown below.

    Code:
    Sub m_ctlBNext_Click()
    
    
        If Me.TheParentForm.Recordset.RecordCount = Me.TheParentForm.CurrentRecord _
                        Or Me.TheParentForm.NewRecord Then
    
    
            If Me.CycleFrn = True Then
    
    
                DoCmd.GoToRecord , Me.TheParentForm.Name, acFirst
    
    
                Exit Sub
    
    
            Else
    
    
                MsgBox "Your at the last record"
    
    
                Exit Sub
    
    
            End If
    
    
        End If
    
    
        DoCmd.GoToRecord , Me.TheParentForm.Name, acNext
    
    
    End Sub
    If IRC Chip Pearson had a pretty good write up on custom classes. If you google it you should find it.
    Same with Withevents.

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by NightWalker View Post
    @ Moke,
    @Bob

    Thank you for your DB. I hope you dont mind but i took some of the code from it and used it in mine.
    Not at all. Use as much as you like. Glad it was of use
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

Please reply to this thread with any new information or opinions.

Similar Threads

  1. changing a forms record source and control sources in code
    By markjkubicki in forum Programming
    Replies: 1
    Last Post: 02-21-2019, 03:11 PM
  2. Replies: 3
    Last Post: 05-07-2015, 07:02 AM
  3. Replies: 5
    Last Post: 04-22-2015, 02:05 PM
  4. Multiple forms to add a record to the table
    By AmaroNeto in forum Forms
    Replies: 6
    Last Post: 01-16-2015, 01:27 PM
  5. multiple tables, multiple forms, one record
    By FullyBaked in forum Forms
    Replies: 7
    Last Post: 10-24-2011, 04:27 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