Search code examples
ms-accessms-access-2016

How to make textbox display difference in table size


I have two tables, A and B. I always know that table B is going to consist of a smaller number of entries. For the sake of argument, lets say that table A contains 5 entries and table B contains 2 entries. I always know that table B is going to consist of a smaller number of entries.

I want to have a form display the difference in the size of the two tables within a textbox. So in this case it should display a value of 3.

I have never used VBA before, and I am a bit confused on how to actually get the textbox to display this. I tried setting up a "before update" script, but I have had no luck. If someone could help me out, that be great.


Solution

  • In a form, use below expression to textbox control source.

    =DCount("*","[Table1]")-DCount("*","[Table2]")
    

    enter image description here