Conditional VBA programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • crazykatie12346
    New Member
    • Jun 2008
    • 1

    Conditional VBA programming

    Hi all, thanks for reading!

    First of all I have no experience with VBA at all... I don't want to try and learn if it won't accomplish what I need. So here's my question:

    I'm creating a client database for a nonprofit org. The data is just demographics for grant reporting...

    Is it possible to do a code that determines whether a client is below the poverty line based on two separate fields [income(which will be a range, not a specific $ amount) and family size]? Also the poverty line obviously will change every year, will that be a problem?

    If this is possible, could someone point me in the general direction??

    Thank you so much for your time,

    Katie
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    No real code is needed for a case like this.
    Best to store the poverty line value in a separate table.
    Now link the persons table to this table and specify the conditions like:

    select name, income from tblPerson as A INNER JOIN tblPovertyLine as B ON (A.Income between B.Bottomine and B.TopLine and A.familyno equal B.FamilyNumber)

    The INNER JOIN can be used to specify the conditions as you need them. Just make sure the proper fields are used.

    Getting the idea ?

    Nic;o)

    Comment

    • youmike
      New Member
      • Mar 2008
      • 69

      #3
      A couple of general thoughts:

      1. What Nico5038 offered is not VBA coding, but SQL. If you find trying to write correct SQL takes more time than you have, it is nearly always possible to construct a query to do the job using the query grid. I'd say you could do it in this case. Using the grid is almost always quicker and if, having used the grid, you find that you need to edit the underlying code, it can be seen using the SQL view of the query. It's a good way to learn SQL, which like all computer programming languages has very tight rules. If you do change code, Access checks what you've done and highlights mistakes.

      2. Regarding VBA, the bottom line is that it can achieve pretty much anything you'll ever need - you just have to learn how to use it. If you have to make significant use of Access, you'll find yourself drawn down this route, because apart from the "do anything" factor, embedded VBA coding is actually easier to maintain I think, and the nature of your projects is likely to make them get more complex as time goes by - to satisfy the needs of your users. For these reasons, I'd say that learning VBA will reply the time spent in the long term.

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        How about posting some data displaying Income Ranges and Family Sizes that would qualify individuals who would be classified at the Poverty Level?

        Comment

        Working...