Results 1 to 15 of 15
  1. #1
    Gabynex9 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2015
    Posts
    8

    Question Adding Value to a field when condition is met


    I have not been able to find the way to ask this so google has been of no help so if you could name something that does this that would be great!
    I need for a valued to be changed in a row after it checks for how many rows have another value, counting how many and that number making it the amount field.
    Example:
    Fields- Name sponsor amount
    I want access to show how many people have been sponsored by Gabriel... So if 3 where sponsored by Gabriel show 3 to the amount field
    for Gabriel row! Any way to do this or an easier way?
    I for it to check it every time a user is added incase the user added is sponsored by Gabriel add it automatically! Thanks again!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    You want every record for Gabriel to show how many records Gabriel has? That is not necessary. An aggregate query can do the count.

    SELECT [Sponsor], Count([Name]) AS Amount FROM tablename GROUP BY [Sponsor];
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Gabynex9 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2015
    Posts
    8

    Post

    Quote Originally Posted by June7 View Post
    You want every record for Gabriel to show how many records Gabriel has? That is not necessary. An aggregate query can do the count.

    SELECT [Sponsor], Count([Name]) AS Amount FROM tablename GROUP BY [Sponsor];


    Something like but no, not just Gabriel any name the would be inputed lets say... You enter harry well i would like the amount field check if there are
    any sponsors with harry wich there should not be becouse he is a new sponsor. After I register someone with the sponsor field with the name harry apply that mount of people with harry in the sponsor to amount! Can this be done?

    Lets say tom and billy where found by harry well, access should make that count in the sponsor field and add the amount to the amount field.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Gabriel and all others. Yes, the aggregate query will do that. That's what the 'GROUP BY' clause is for. Did you try?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Gabynex9 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2015
    Posts
    8

    Still not working

    Quote Originally Posted by June7 View Post
    Gabriel and all others. Yes, the aggregate query will do that. That's what the 'GROUP BY' clause is for. Did you try?
    The instructions you gave me did not work, how would I use these in the query Im having a hard time figuring this out please help!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Exactly what did you do? Why didn't it work - error message, wrong results, nothing happens? Post examples of raw data and desired output or provide db for analysis. Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Gabynex9 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2015
    Posts
    8

    What I want to do is...

    Example, You see "Hiram" the row in my Extreme promotores tables right? I want to make a Query that checks the Pm-Sponsors column and see if anybody was sponsored by
    Hiram, count how many time his name appears in the sponsor column and that value be presented in the Query but I want this process done for everyone so all the name show up
    with the people they brought in. Then I would multiply this amount (people brought in by each name) and my action table record and receive the amount they are going to be paid. (The action table only has 1 value that can change over time)
    Attached Files Attached Files

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Don't see the query I suggested in the db. Consider:

    SELECT [EXTREME PROMOTORES].[PM-SPONSOR], Count([EXTREME PROMOTORES].[PM-NOMBRE]) AS [CountOfPM-NOMBRE], Max(Acciones.[accion]) AS Rate
    FROM [EXTREME PROMOTORES], Acciones
    GROUP BY [EXTREME PROMOTORES].[PM-SPONSOR];
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Gabynex9 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2015
    Posts
    8
    Quote Originally Posted by June7 View Post
    Don't see the query I suggested in the db. Consider:

    SELECT [EXTREME PROMOTORES].[PM-SPONSOR], Count([EXTREME PROMOTORES].[PM-NOMBRE]) AS [CountOfPM-NOMBRE], Max(Acciones.[accion]) AS Rate
    FROM [EXTREME PROMOTORES], Acciones
    GROUP BY [EXTREME PROMOTORES].[PM-SPONSOR];
    The query you said I didn't put it becouse everytime I past it I get an error, Some chunk of the expressions might somewhere but I dont know this, Do i just past all of the expression into the build? Im a beginner, really! And thanks for your patience!

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    The first query was just an example and you would have to replace with your actual table and field names because I did not know them.

    Copy/paste the second suggested SQL statement into SQL View of query builder then switch to Design View to see that structure.

    I built that query with the query builder. After opening the query builder and selecting the table, I clicked the TOTALS button on ribbon. This makes aggregate functions available.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    Gabynex9 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2015
    Posts
    8

    Almost Done

    Quote Originally Posted by June7 View Post
    The first query was just an example and you would have to replace with your actual table and field names because I did not know them.

    Copy/paste the second suggested SQL statement into SQL View of query builder then switch to Design View to see that structure.

    I built that query with the query builder. After opening the query builder and selecting the table, I clicked the TOTALS button on ribbon. This makes aggregate functions available.
    Yes it did the count but in a normal builder I would do [table]*[table] to multiply the values how would I multiply the COunt of the value I get with accion I also get? That would be all

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    First build the aggregate query. Then use it in another query or as the source for a report. Do the multiplication calc there.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    Gabynex9 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2015
    Posts
    8
    Quote Originally Posted by June7 View Post
    First build the aggregate query. Then use it in another query or as the source for a report. Do the multiplication calc there.
    Yeah, im not getting that... Sorry im not really good at all this.

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Not getting what? How to open query builder? How to select a query as data source for another query? How to build expression in query? How to use query as RecordSource for a report?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    Gabynex9 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2015
    Posts
    8
    Quote Originally Posted by June7 View Post
    Not getting what? How to open query builder? How to select a query as data source for another query? How to build expression in query? How to use query as RecordSource for a report?
    Got it thanks man

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

Similar Threads

  1. require input in a field when condition met
    By edwardcga in forum Forms
    Replies: 12
    Last Post: 11-01-2013, 10:36 AM
  2. Replies: 4
    Last Post: 10-16-2013, 01:05 PM
  3. Replies: 4
    Last Post: 08-06-2012, 10:25 AM
  4. DLookup with multiple field condition
    By agent- in forum Programming
    Replies: 4
    Last Post: 10-15-2011, 05:17 PM
  5. Replies: 1
    Last Post: 11-04-2010, 12:57 PM

Tags for this Thread

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