Results 1 to 8 of 8
  1. #1
    senna is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    7

    Formula for form!!! Urgent plzzzz!

    Hi there,

    I need a formula such as =Sum(IIf([claim sighted]=2,1,0)) for a form in my database. This formula i used for another form and is only an example of the type of solution i am looking for as it worked for my other requirement. Would a formula like this work for the following requirement?

    The values i want to count are frequently duplicated text IE: A99999 or A88888 and i only want to count the number of instances each of these values come up when [sighted]=2.

    Example.

    TAG --------------- SIGHTED
    A77777 ----------------2
    A77777 ----------------2
    A88888 ----------------1
    A88888 ----------------1
    A88888 ----------------1
    A99999 ----------------2
    A99999 ----------------2


    A99999 ----------------2

    In this example, the final count should be 2. As there are 2 different TAGS which HAVE BEEN sighted.

    Can anyone help? URGENT! Thank you, any help greatly appreciated!

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    Are Tag and Sighted stored in a table? If so you can use a query.

    SELECT count(TAG)
    FROM myTable
    GROUP BY TAG, SIGHTED
    HAVING SIGHTED = 2;

    ^^I think that's good syntax. Dont have Access right now to check.

    Then you can use the DLookup() function to pull the count into the form from the query.

  3. #3
    senna is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    7
    Thanks Shabz, ill give it a try. Not too sure where to put this coding though.
    At the moment yes they are in the table
    and I have a query for the form, which contains these fields in them.

    WHere do I go from here?

  4. #4
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    Create a separate query for that. Then, create an unbound textbox that holds:
    =DLookup("FieldName", "QueryName")

    Keep the quotes

  5. #5
    senna is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    7
    I am not sure where to put that first code though...
    if i create a new query, where do i place that first code?

  6. #6
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    You probably have the query in design view. Open it in SQL view and paste. remember to change the myTable to the proper table name.

  7. #7
    senna is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    7
    Ok... I have pasted this into SQL
    SELECT count(tag)
    FROM [Sales Table]
    GROUP BY tag, sighted
    HAVING sighted=2;


    and this onto my form

    =DLookUp("tag","COUNT QUERY")


    i get an #error

  8. #8
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    Does the query return a result when you switch from sql view to datasheet view? My SQL syntax could be off.

    Also, it could be that "COUNT QUERY" should be "[COUNT QUERY]"

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

Similar Threads

  1. Formula for form
    By chanoc24 in forum Forms
    Replies: 3
    Last Post: 08-18-2010, 10:40 PM
  2. Creating Formula In The Form
    By mastee in forum Access
    Replies: 3
    Last Post: 04-19-2010, 05:52 PM
  3. Replies: 0
    Last Post: 11-10-2009, 12:06 PM
  4. Urgent: Need to make a transaction form
    By Sheharyar_rr in forum Access
    Replies: 1
    Last Post: 10-31-2009, 10:52 AM
  5. Query to run from a FORM VERY URGENT
    By prag in forum Forms
    Replies: 14
    Last Post: 10-08-2009, 01:51 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