Consulting

Results 1 to 4 of 4

Thread: Comparing tables or Recordset?

  1. #1
    VBAX Newbie
    Joined
    Jan 2018
    Posts
    3
    Location

    Comparing tables or Recordset?


    Hello everyone. I'm new to the forum and new to the VBA world with Access.

    I am trying to get through my first challenge but I find something tangled. It's about the following:
    I have a form in access where when selecting a festive date (example December 25) and clicking on a button, a report is printed. (which is the result of a query). Now, if the user prints it today, January 19, it shows the report correctly. But if you print it again on January 28, the user wants to see the new, modified and / or deleted records between January 19 and 28. In other words, the user does not want to see the records that did not have any change.

    So what I have thought is to create a table that stores the result of the first time the report was executed and then another table the second time they executed the report and make a comparison of tables.

    What confuses me is that I do not have a date field in which the report was executed.

    Could someone tell me if the previous one is a good solution and how can I do it? Do I should use a recordset?

    Many thanks, I really appreciate any comment.


  2. #2
    VBAX Tutor
    Joined
    Mar 2014
    Posts
    210
    Location
    youd want a form, with 2 text boxes:
    txtDate1 (dec 25)
    txtDate2 (jan 28)

    Q1 would pull the data from dec, select * from table where [date] =forms!myForm!txtDate1
    Q2 would pull the data from Jan...

    then Q3 would join the 2 queries above and to see what changed:.... where Q1.field = Q2.field and Q1.value <> Q2.value

    you can also do 2 queries to do OUTER joins to see what was added in Q2 not in Q1,
    and Q5 to do it vise versa

  3. #3
    VBAX Newbie
    Joined
    Jan 2018
    Posts
    3
    Location
    Thank you for your answer ranmman. I dont have a form with the dates textboxes. That's why I need to take the date of today from the system and save them in a table, is't it??

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    The method that ranman proposes uses a blank form (No Record Source) with two UnBound fields formatted for Dates where you can enter 2 dates for use with the query(s).

    However ideally rather than a second table you would have a "last modified" date field in the original table, a "deleted" (Yes/No) field and also a "report date" field.
    When you run the report the "Report Date" is set to the current date and your query is set to ignore all records unless the "Last modified" field date is after the Report Date or there is no report date.
    The Last modified date is automatically set using VAB code on the Data Entry/Edit Form, the Report date can be set using an "Update Query" when the report is run.

    Otherwise every time you run the report you have to update the second table, which is just duplication of data.

    ps the advantage of the "deleted" field, rather than actually deleting the record means that if someone makes a mistake or a record needs to be resurrected you just untick the box.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •