Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Count for totals

Discussion in 'Information Technology' started by Roger Bell, Nov 8, 2005.

Tags:
  1. Roger Bell

    Roger Bell
    Expand Collapse
    Guest

    I have inherited a data base that is not truly relational and already has
    loads of data in it. There are 6 seperate fields for Children's names EG:
    Namechild1, Namechild2 etc etc. There is then a text box called Number of
    children in family which has to manually added (no big deal i guess) and the
    number enter into this field. Is there any way I can write some code in this
    text box that will automatically count the number of children for each
    record, which will naturally change then as children are added or deleted.
    Thanks for any help
     
  2. Loading...

    Similar Threads Forum Date
    Ashdoc's Movie Review---The Accountant Theatre, Movies & Cinema Oct 21, 2016
    Gurmat Vichaar | Futility Of Counting Paaths | April 12, 2016 Gurmat Vichaar Apr 23, 2016
    wolf count Blogs Oct 17, 2015
    recount Blogs Oct 17, 2015
    Events Banda Singh Bahadur's Martyrdom - An Eyewitness Account History of Sikhism Mar 26, 2015

  3. Larry Linson

    Larry Linson
    Expand Collapse
    Guest

    "Roger Bell" wrote

    > I have inherited a data base that is not truly relational
    > and already has loads of data in it. There are 6 sep-
    > erate fields for Children's names EG: Namechild1,
    > Namechild2 etc etc. There is then a text box called
    > Number of children in family which has to manually
    > added (no big deal i guess) and the number enter
    > into this field. Is there any way I can write some
    > code in this text box that will automatically count
    > the number of children for each record, which will
    > naturally change then as children are added or deleted.


    You can write code in a standard module, if you wish, and call that from
    within a Query, to count those fields.

    You can write code, but not in the bound TextBox... calculated Controls
    cannot be bound. You could have a Calculated Text Box on your Form, unbound,
    and then copy the value to a bound Text Box.

    Basically the code for a calculated Text Box will look something like this
    (air) code:

    = IIF(Not IsNull(txtChild1), 1, 0) +
    IIF(Not IsNull(txtChild2), 1, 0) +
    IIF(Not IsNull(txtChild3), 1, 0) +
    . . .
    IIF(Not IsNull(txtChildN),1,0)

    You may have to fully-qualify the reference if it is not patently obvious to
    Access that "txtChild1" refers to a Text Box.

    In the Form's module you can use the Me!txtChildN notation, simplifying the
    qualification of the reference.

    BUT, it might be a lot better in the long-run if you would invest a little
    more time, some Queries, and perhaps a little code, in extracting what
    appears to be related child information into a related table.

    Larry Linson
    Microsoft Access MVP
     

Share This Page