How to be sure that the recordsets of two different forms are the same?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ricardo de Mila
    New Member
    • Jan 2011
    • 41

    How to be sure that the recordsets of two different forms are the same?

    I have two different forms that uses the same query as data origin, but sometimes the filters are changed and other times I have to resyncronize the informations.
    The requery procedure takes so long and if the forms already have the same recordset, I don't have to spend that time.
    Is there any way to be sure that the recordset of Form1 is exactly the same as the recordset of Form2? I mean: Any tag or checksum or special function or something like this that could say that two recordsets are identical before a require procedure?

    Best regards
    Ricardo de Milano
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    + You can use a custom event between forms to trigger a requery; however, what I suggest is that you either look at code to alter the filter dynamically instead of using two separate forms for the same data, or look at recreating the form using a tabbed control instead of dual forms.

    Custom events can be fussy to work with, the dynamic filters are straight forward to implement, and the tabbed control is the next easiest method.

    + Any particular reason behind the two separate forms.?

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32661

      #3
      I typically create the SQL for the recordset first. Once that's done I compare this with the form's .Recordset property. If they're the same I do no more. If they're different I set .Recordset from the string I worked out.

      I don't understand what you're asking about as I see no scenario where matching two forms makes sense, and if it did there's nothing in your question to indicate which should be considered the master, or correct. Once you know that though, you'd simply compare the other with the master and apply it only if it were different. Very much as you would normally when it comes to applying a .Recordset that you've worked out to be what's required.

      Comment

      • hvsummer
        New Member
        • Aug 2015
        • 215

        #4
        I think we can call
        Code:
        somevar = Forms!FormName.filter
        Me.filter = Somevar
        if that problem come from filter

        but I think you should create new recordset from your query SQL then bind recordset to those 2 form as NeoPa suggestion

        Comment

        • zmbd
          Recognized Expert Moderator Expert
          • Mar 2012
          • 5501

          #5
          hvsummer but I think you should create new recordset from your query SQL then bind recordset to those 2 form as NeoPa suggestion
          That is not what Neopa suggested.


          hvsummer I think we can call
          Code:
          somevar = Forms!FormName.filter
          Me.filter = Somevar
          if that problem come from filter
          that however doesn't satisfy OP's question, it only compares the filters applied and OP clearly states that the forms may have different filters while based on the same record-set.

          The problem apparently arising if the record set is altered in one form then needs to be updated in the second form along with the difference in filters; however, this is just a guess on my part as OP has not provided that information.

          As NeoPa indicates, and as I have alluded to, this scenario doesn't make sense and we need more information from OP in order to provide a much clearer course of action.
          Last edited by zmbd; Dec 31 '15, 06:39 AM.

          Comment

          • hvsummer
            New Member
            • Aug 2015
            • 215

            #6
            @zmbd:
            I have two different forms that uses the same query as data origin, but sometimes the filters are changed and other times I have to resyncronize the informations.
            The requery procedure takes so long and if the forms already have the same recordset, I don't have to spend that time.
            Is there any way to be sure that the recordset of Form1 is exactly the same as the recordset of Form2? I mean: Any tag or checksum or special function or something like this that could say that two recordsets are identical before a require procedure?
            when I read this, I tho that everyone could know that he need to synchronize record between 2 form.
            we can say he need to make sure 2 record that currently show up in form is the same.

            there are 2 problem could occur here:

            First, if he only want to make sure 2 form have same filter, same order, same currently row.

            Solution for this is make a form with subform, link 2 form together in the same screen.

            Second, if he want to make sure the currently record are the same, no matter filter, no matter order, don't even care about filter.

            Then we just need to ask him what is the unique ID value field on his query, and use any method to save that value in somewhere (table, collection, dictionary) in afterupdate_eve nt of the Unique_ID value field. after that, Recall/show that Unique_ID in 2 table at the sametime
            --> this method somewhat similar to Me.recordset = rs.Open(SQL) but I did not test the result to see whether it's the same way or not.

            I don't know if my Idea is good or not, but, I'm sure that my predict have veryhigh strike rate.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32661

              #7
              Originally posted by Ricardo de Milano
              Ricardo de Milano:
              Is there any way to be sure that the recordset of Form1 is exactly the same as the recordset of Form2?
              This is an interesting question in as much as the intention isn't clear.
              Originally posted by Ricardo de Milano
              Ricardo de Milano:
              Is there any way to be sure that Form1.Recordset is exactly the same as Form2.Recordset?
              Like this, we are clearly talking about one specific property. This is how I interpreted the question when I posted.
              Originally posted by Ricardo de Milano
              Ricardo de Milano:
              Is there any way to be sure that the eventual resultant recordset of Form1 is exactly the same as the eventual resultant recordset of Form2?
              Like this, we're interested in what is shown in the form regardless of which properties were used to get to this result. This may, or may not, even include sorting.

              While we are all reading the same words, it may be that we're interpreting them differently. This is one of the drawbacks of having a responsive and popular forum where only English is used. Of course, allowing other languages is a whole different ballgame and I'm not suggesting that. Simply that working in other languages can be difficult for both members asking questions and those answering them.

              Comment

              • Ricardo de Mila
                New Member
                • Jan 2011
                • 41

                #8
                I really should have to had asked this to you before. I feel you are totally right. But now I will have a lot of work to correct my mistake. The tabbed controle would save me a lot of time.
                Thank you Zmbd.

                Comment

                • Ricardo de Mila
                  New Member
                  • Jan 2011
                  • 41

                  #9
                  Dear NeoPa... About the scenario that has originated by problem, please, keep in mind that there are a lot of information to be showed in just one form, so I have divided the showing in 5 forms. This causes some problems with sincronization and I was wondering if there is any "magic" function to say that two recordsets are exactly the same. I'm not sure if I understood what you mean about comparing both recordset.. Are you stating something like

                  if RS1 = RS2 then dosomething

                  ?

                  Thank you very much for answering and best regards.
                  Ricardo

                  Comment

                  • Ricardo de Mila
                    New Member
                    • Jan 2011
                    • 41

                    #10
                    Hello everybody...
                    I'm not sure I'm making a basic mistake, but here is my detailed problem and the concepts I have in my mind to originate the question:
                    I have a specific form FRMa00 with the field FLD1.
                    I have two other forms that are FRMb00 and FRMb01. The recordset for both FRMb00 and FRMb01 are the same there's a field FLD2 in this recordset. The filter is FLD2=FRMa00.FLD 1.
                    If I change the record in FRMa00, I have to requery FRMb00 to update the information. The recordsource is the same and the Filter is the same, but I have to FRMb00.Requery.
                    In some cases, even requerying FRMb00, the recordset in FRMb01 will not change just due to a coincidence.
                    The question is: Is there any way to be sure that the recordset of FRMb01 (that has been already requeryed) is the same as FRMb01's recordset that was not requeryed?

                    Best regards
                    Ricardo
                    Last edited by zmbd; Jan 2 '16, 06:02 PM.

                    Comment

                    • zmbd
                      Recognized Expert Moderator Expert
                      • Mar 2012
                      • 5501

                      #11
                      Ricardo,
                      I was going to split this last post from the thread as a new question; however, after a very careful read, it appears to be the exact same question as your first post, just a little more detailed...

                      Therefor, the same answers to the dilemma will still apply

                      My second thought here is to merge your last post with the first... can you help me out here?

                      Comment

                      • zmbd
                        Recognized Expert Moderator Expert
                        • Mar 2012
                        • 5501

                        #12
                        The tabbed controle would save me a lot of time.
                        You might find the following articles to be helpful:
                        ) Using Tabbed Pages on a Form
                        ) Accessing Tabs on a Tab Control

                        IN this particular case, you might want to avoid the subform approach within the tabbed control.

                        Comment

                        • NeoPa
                          Recognized Expert Moderator MVP
                          • Oct 2006
                          • 32661

                          #13
                          Hi Ricardo.

                          The word 'recordset' has two meanings.
                          1. .Recordset is the name of a property that can be found on Form and Report objects. Comparing this with another .Recordset property would be comparing two strings for equivalence.
                          2. Recordset is also a word that refers to items that are found in such objects, but are also found elsewhere. Although these can be described using table names, query names and SQL strings, the word actually refers to the resultant set of records. These can be considered the same even when the the strings defining them are not.

                            An example for that is :
                            Code:
                            [TableName]
                            &
                            Code:
                            SELECT *
                            FROM   [TableName]

                          You can see from the above example that these two recordsets would be considered to be the same when treating the word as in point #2, but not the same when treating the word as in point #1. This is why different experts have given different, and apparently contradictory, advice. If we knew which term you were thinking of when you asked the question it would be helpful.

                          Comment

                          Working...