Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    justair07 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Flordia
    Posts
    63

    Duplicated Data Issue

    Hello everyone,

    Attached is a sample of my project to help you see the issue yourself instead of me trying to explain. It's kind of confusing.

    Once you open the db. open up the frmQuoteLog and the frmPDMontior. You will notice one record is displayed in the frmPDMonitor (Justin Ryan). This is correct.

    Now to test out the issue leave open the frmPDMonitor and frmQuoteLog at the same time. Go to frmQuotLog, go to the first record, make the "Sales Coordinator" = "Chris April", then check the box that says "Display on Product Design Monitor", then press the "Save Changes" button.

    Then look at the frmPDMonitor and you will notice the new record is now displayed on the form. This is correct as well.

    Leaving open both forms, go to frmQuoteLog and uncheck the box you previous checked on the first record, then press "Save Changes".

    Then look again at the frmPDMontior and notice that the previous record is gone but the remaining record is now duplicated.



    Only when I close the frmPDMonitor and reopen it, does the duplication go away.

    How can I avoid this duplication without closing and reopening the frmPDMonitor? The purpose of this form is to be ran 24/7.

    Sorry for the long explanation but I wanted to make sure I explained everything for the best possible solution.

    Completing this project is a top priority for me and could really use some the help.

    As always thank you,

    -Justin
    Attached Files Attached Files

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Requery your data.
    Me.Requery
    HTH

  3. #3
    justair07 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Flordia
    Posts
    63
    Quote Originally Posted by burrina View Post
    Requery your data.


    HTH
    Hi Dave,

    Thank you for the reply. How do I requry the data. Sorry I'm still new to Access

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Well, Requery won't work because frmPDMonitor has unbound controls. Your code is populating unbound controls, not displaying records. Would need code to set controls back to null.

    The form has 20 sets of unbound controls. This means limited to 20 sets of data.

    Why is this not just one set of controls bound to fields?
    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.

  5. #5
    justair07 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Flordia
    Posts
    63
    Quote Originally Posted by June7 View Post
    Well, Requery won't work because frmPDMonitor has unbound controls. Your code is populating unbound controls, not displaying records. Would need code to set controls back to null.

    The form has 20 sets of unbound controls. This means limited to 20 sets of data.

    Why is this not just one set of controls bound to fields?
    Hello June7,

    Using one set of bound controls and requery on a Timer set at 1000 causes the form to flicker and is extremely distracting. The method I used was a work around to avoid the flickering.

    How could I reset the controls back to null? I think I understand you correct. Are you saying that I need the code to reset the controls to Null and then reestablish what data needs to be repopulated?

    Sorry I'm still learning.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Code populates the controls so code must de-populate them. Yes, if you de-populate all then must run the code again to re-populate with revised data.
    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.

  7. #7
    justair07 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Flordia
    Posts
    63
    Quote Originally Posted by June7 View Post
    Well, Requery won't work because frmPDMonitor has unbound controls. Your code is populating unbound controls, not displaying records. Would need code to set controls back to null.

    The form has 20 sets of unbound controls. This means limited to 20 sets of data.

    Why is this not just one set of controls bound to fields?
    Thanks again June 7,

    Here is the code I used to populate the controls:

    Code:
    Public Sub LoadMyForm(frm As Access.Form)
    On Error GoTo Error_Handler
    '    Dim db              As DAO.Database
        Dim rs              As DAO.Recordset
        Dim x               As Integer
    
    '    Set db = CurrentDb()
        Set rs = db.OpenRecordset("qryPDMonitor", dbOpenSnapshot)
    
        For x = 1 To 16
            If rs.EOF Then Exit For
            With frm
            frm.Controls("qn" & x) = rs!QuoteLogNumber
            frm.Controls("cust" & x) = rs!Customer
            frm.Controls("sales" & x) = rs![Sales COOrd]
            frm.Controls("prod" & x) = rs!ProductDesignInitials
            frm.Controls("submit" & x) = rs!dtmTimeSubmitted
            frm.Controls("total" & x) = rs!Expr1
            frm.Controls("c" & x) = rs!PartsCompleted
            frm.Controls("e" & x) = rs!ynExpedite
            End With
            rs.MoveNext
        Next
    
    Error_Handler_Exit:
        On Error Resume Next
        rs.Close
        Set rs = Nothing
    '    Set db = Nothing
        Exit Sub
    
    Error_Handler:
        MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
                "Error Number: " & Err.Number & vbCrLf & _
                "Error Source: LoadMyForm" & vbCrLf & _
                "Error Description: " & Err.Description, _
                vbCritical, "An Error has Occured!"
        Resume Error_Handler_Exit
    End Sub
    This code is called from a Timer Event on my forms Load Event.

    Like I said I'm still learning. Could you take a look at the code and suggest a solution that de-populates the controls?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    It would be the same loop structure only instead of referencing recordset to pull values, just = Null.
    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
    justair07 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Flordia
    Posts
    63
    Quote Originally Posted by June7 View Post
    It would be the same loop structure only instead of referencing recordset to pull values, just = Null.
    Okay but if I use this in the same module that is called by a timer event triggered every 1 second. Wont that cause the screen to flicker blank every second?

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Yes, but maybe so fast hardly noticeable. Maybe not the 'jumpy' flicker caused by requery/refresh.
    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
    justair07 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Flordia
    Posts
    63
    Quote Originally Posted by June7 View Post
    Yes, but maybe so fast hardly noticeable. Maybe not the 'jumpy' flicker caused by requery/refresh.
    Here's what I put:
    Code:
    Public Sub LoadMyForm(frm As Access.Form)
    On Error GoTo Error_Handler
    '    Dim db              As DAO.Database
        Dim rs              As DAO.Recordset
        Dim x               As Integer
    
    '    Set db = CurrentDb()
        Set rs = db.OpenRecordset("qryPDMonitor", dbOpenSnapshot)
    
        For x = 1 To 16
            If rs.EOF Then Exit For
            With frm
            frm.Controls("qn" & x) = Null
            frm.Controls("cust" & x) = Null
            frm.Controls("sales" & x) = Null
            frm.Controls("prod" & x) = Null
            frm.Controls("submit" & x) = Null
            frm.Controls("total" & x) = Null
            frm.Controls("c" & x) = Null
            frm.Controls("e" & x) = Null
            End With
            rs.MoveNext
        Next
        
        For x = 1 To 16
            If rs.EOF Then Exit For
            With frm
            frm.Controls("qn" & x) = rs!QuoteLogNumber
            frm.Controls("cust" & x) = rs!Customer
            frm.Controls("sales" & x) = rs![Sales COOrd]
            frm.Controls("prod" & x) = rs!ProductDesignInitials
            frm.Controls("submit" & x) = rs!dtmTimeSubmitted
            frm.Controls("total" & x) = rs!Expr1
            frm.Controls("c" & x) = rs!PartsCompleted
            frm.Controls("e" & x) = rs!ynExpedite
            End With
            rs.MoveNext
        Next
    
    Error_Handler_Exit:
        On Error Resume Next
        rs.Close
        Set rs = Nothing
    '    Set db = Nothing
        Exit Sub
    
    Error_Handler:
        MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
                "Error Number: " & Err.Number & vbCrLf & _
                "Error Source: LoadMyForm" & vbCrLf & _
                "Error Description: " & Err.Description, _
                vbCritical, "An Error has Occured!"
        Resume Error_Handler_Exit
    End Sub
    But I must have done something wrong since the controls only display blank now.

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Guess I should have mentioned not to cycle through the recordset when setting the fields to Null. The recordset is not relevant for that.

    BTW, since you have With frm, no need to repeat frm on each line. That's the reason for using With, less typing.
    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
    justair07 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Flordia
    Posts
    63
    Quote Originally Posted by June7 View Post
    Guess I should have mentioned not to cycle through the recordset when setting the fields to Null. The recordset is not relevant for that.

    BTW, since you have With frm, no need to repeat frm on each line. That's the reason for using With, less typing.
    Hi June7,

    So which line/s do I need to remove?

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    If rs.EOF Then Exit For

    and

    rs.MoveNext
    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.

  15. #15
    justair07 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Flordia
    Posts
    63
    June7,

    Thank you very much. One error though I keep getting the following error:
    Click image for larger version. 

Name:	Capture.JPG 
Views:	17 
Size:	21.9 KB 
ID:	16380

    I had to comment out the line that referenced control e jus tto get it to run without error, see below:
    Code:
     For x = 1 To 16
            'If rs.EOF Then Exit For
            With frm
            frm.Controls("qn" & x) = Null
            frm.Controls("cust" & x) = Null
            frm.Controls("sales" & x) = Null
            frm.Controls("prod" & x) = Null
            frm.Controls("submit" & x) = Null
            frm.Controls("total" & x) = Null
            frm.Controls("c" & x) = Null
            'frm.Controls("e" & x) = Null
            End With
            'rs.MoveNext
        Next
    Any idea why this is happening and why it's only an issue with this control?

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

Similar Threads

  1. Blank duplicated values
    By uframos in forum Queries
    Replies: 3
    Last Post: 03-25-2013, 12:46 PM
  2. Combine duplicated data in a report
    By padfoot in forum Reports
    Replies: 3
    Last Post: 03-24-2012, 08:41 AM
  3. Duplicated values in query
    By truent in forum Queries
    Replies: 6
    Last Post: 03-03-2012, 01:45 PM
  4. Results from query are duplicated
    By funkygoorilla in forum Queries
    Replies: 7
    Last Post: 10-30-2011, 05:50 PM
  5. Lines duplicated with Queries
    By mari_hitz in forum Queries
    Replies: 3
    Last Post: 10-17-2011, 06:38 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