Results 1 to 3 of 3
  1. #1
    thetuyen is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    2

    Post total many fields by function


    I'm Vietnamese and I'm not good in english. Please to sympathize with me.
    I create a table with 45 fields in it: ID, month, year, t1,t2,t3...t40. The fields t1, t2.. t40 will have value(format is text): 0.5P or 1 or 0.5 or Null . I want to create total of that with convention : 0.5p = 0.5; 1=1, 0.5 = 0.5, null =0, orther value= 0. Then I have SQL like:
    Code:
     SELECT
    IIf([t1]="1",1,IIf([t1]="0.5" or [t1]="0.5P", 0.5,0)) + 
    IIf([t2]="1",1,IIf([t2]="0.5" or [t2]="0.5P", 0.5,0)) + 
    .....
    IIf([t40]="1",1,IIf([t40]="0.5" or [t40]="0.5P", 0.5,0)) +
    AS Totalfiels
    ....
    It's very long and I thinh that it's stupid. And I try to write a function for it by VBA, But I can't. hu hu.... I'm studying access and I'm not intelligent. Please to help me create that function. Thanh you very very much.

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    do not have fields t1-t40. make a second table with 3 columns (Ttable) first column is autonumber primary key. 2nd column is cross reference to first column foreign key. 3rd column is T value.

    make a data entry form - and then insert new Ttable as subform.

    you have a decision; you can convert the value (i.e. 0.5p to .5) in the form at first data entry. Or you can store the original value 0.5p and convert it during queries/reporting. Now there is only 1 T field (not 40) so it will be easier to write solution.

  3. #3
    thetuyen is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    2
    Quote Originally Posted by NTC View Post
    do not have fields t1-t40. make a second table with 3 columns (Ttable) first column is autonumber primary key. 2nd column is cross reference to first column foreign key. 3rd column is T value.

    make a data entry form - and then insert new Ttable as subform.

    you have a decision; you can convert the value (i.e. 0.5p to .5) in the form at first data entry. Or you can store the original value 0.5p and convert it during queries/reporting. Now there is only 1 T field (not 40) so it will be easier to write solution.
    Thank you very much.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Total a Query
    By Bridgid in forum Queries
    Replies: 0
    Last Post: 09-05-2009, 02:51 PM
  2. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 AM
  3. 7 day average and total
    By jannie in forum Access
    Replies: 1
    Last Post: 05-14-2009, 05:52 PM
  4. total in textbox
    By micfly in forum Access
    Replies: 3
    Last Post: 11-09-2008, 11:24 AM
  5. Total Number of Fields allowed on a Form
    By tpearo in forum Forms
    Replies: 1
    Last Post: 12-15-2005, 06:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums