Results 1 to 7 of 7
  1. #1
    HotelierDream is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    31

    Sync Subforms

    Hello all,



    I am making a DB for a hotel and I have everything pretty much done but I am having an issue, I created a navigation form with subforms in order to make it easier to use. It also has one report in the navigation form. The problem is that if I try to move to a new date (make a new record) on one form it does not change the record on the others. All the subforms are from one table as it was easier for reporting purposes. How can I make these items sync? See the ZIP with the BE and FE of the database.



    Night Audit Manager.zip

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Changed form_open event to avoid duplicating current date.
    Added code to navigation button click events to add criteria to the recordsource of the forms.
    You'll need additional code for the additional buttons. Not all recordsources are same objects, so be aware of that.
    After changing the input date at the top, clicking the button will automatically requery the form/report.


    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Sub Form_Open(Cancel As Integer)
        DoCmd.Maximize
        If DCount("*", "[Daily Input Report]", "[Input Date]=" & Date) = 0 Then
            DoCmd.GoToRecord , , acNewRec
        End If
    End Sub
    
    
    Private Sub NavigationButton21_Click()
        If IsNull(Me.[Input Date]) Then
        Else
            Me.NavigationSubform.Form.RecordSource = "Select * from [Daily Input Report] Where [Input Date] = #" & Me.[Input Date] & "#"
        End If
    End Sub
    
    
    Private Sub NavigationButton25_Click()
        If IsNull(Me.[Input Date]) Then
        Else
            Me.NavigationSubform.Form.RecordSource = "Select * from [Daily Input Report] Where [Input Date] = #" & Me.[Input Date] & "#"
        End If
    End Sub
    Another way of handling the recordsources without using VBA is like this:
    Click image for larger version. 

Name:	nav2.png 
Views:	35 
Size:	49.2 KB 
ID:	43739
    Last edited by davegri; 12-25-2020 at 10:34 AM. Reason: added image

  3. #3
    HotelierDream is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    31
    Quote Originally Posted by davegri View Post
    Changed form_open event to avoid duplicating current date.
    Added code to navigation button click events to add criteria to the recordsource of the forms.
    You'll need additional code for the additional buttons. Not all recordsources are same objects, so be aware of that.
    After changing the input date at the top, clicking the button will automatically requery the form/report.

    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Sub Form_Open(Cancel As Integer)
        DoCmd.Maximize
        If DCount("*", "[Daily Input Report]", "[Input Date]=" & Date) = 0 Then
            DoCmd.GoToRecord , , acNewRec
        End If
    End Sub
    
    
    Private Sub NavigationButton21_Click()
        If IsNull(Me.[Input Date]) Then
        Else
            Me.NavigationSubform.Form.RecordSource = "Select * from [Daily Input Report] Where [Input Date] = #" & Me.[Input Date] & "#"
        End If
    End Sub
    
    
    Private Sub NavigationButton25_Click()
        If IsNull(Me.[Input Date]) Then
        Else
            Me.NavigationSubform.Form.RecordSource = "Select * from [Daily Input Report] Where [Input Date] = #" & Me.[Input Date] & "#"
        End If
    End Sub
    Another way of handling the recordsources without using VBA is like this:
    Click image for larger version. 

Name:	nav2.png 
Views:	35 
Size:	49.2 KB 
ID:	43739

    First of all, YOU ARE AMAZING!!!! This was just what I needed for the forms!

    Now I have a final issue, how do I get the Report to update when I click on it? Everything else updates except for the Report (M3 Input) that should show the report generated for the date on the main form.

  4. #4
    HotelierDream is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    31
    Also, How would I go about refreshing the Total Revenue / Rooms form when I change the date on the main form?

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Night Audit Input Report-davegri-v01.zip

    Have a look at this. It should work OK with your current BE.

  6. #6
    HotelierDream is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    31
    Thank you so much, you have got to be the nicest person! Also, I looked at the code and it makes a bit more sense now!

  7. #7
    HotelierDream is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    31
    I spoke a tad bit too soon, so it does update the date on the forms but it is displaying information from previous entries. It is like its just changing one record instead of making a new one except it when I look at the Night Audit input table it does in fact make a new record. Sorry to bother you!

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

Similar Threads

  1. Replies: 3
    Last Post: 08-31-2020, 05:02 PM
  2. Replies: 13
    Last Post: 11-05-2017, 05:07 PM
  3. Sync two forms....
    By dennissanford in forum Forms
    Replies: 3
    Last Post: 08-31-2013, 11:33 PM
  4. Replies: 3
    Last Post: 08-29-2012, 02:42 PM
  5. Sync ListBox?
    By rosh41 in forum Forms
    Replies: 4
    Last Post: 06-21-2010, 11:12 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