Results 1 to 7 of 7
  1. #1
    Join Date
    May 2010
    Location
    Islamabad
    Posts
    13

    Get Value from query in a form unbound field without where condition


    hey dearz.

    I have a query which includes 3 fields:

    (1)- Sum of WithDrawalAmount
    (2)- Sum of DepositAmount
    (3)- BalanceAmount (Balance: [Sum Of Deposit Amount]-[Sum Of W/D Amount])



    I have a bound Form including a unbound field name "GrandTotal"

    I want to show query "BalanceAmount" value result in the Form GrandTotal field. how it is possible.

    DLookup and ELookup funcations need the give where condition but i want to show the value without where condition.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    As answered elsewhere, the DLookup "where" argument is not required.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    May 2010
    Location
    Islamabad
    Posts
    13
    please give me example how to ignore where condition.

    i try to use dlookup like this
    =DLookup("[Balance]", "GrandTotalQuery") but it showing #Name? error.

    and also try to use this
    =DLookup("Balance", "GrandTotalQuery", "SumOfW/DAmount = " & Nz([SumOfW/DAmount],0)). but not working.

    any suggession

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    The first should work:

    =DLookup("[Balance]", "GrandTotalQuery")

    You might try bracketing the query name too. Can you post the db if it still doesn't work?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Join Date
    May 2010
    Location
    Islamabad
    Posts
    13
    dear sir

    first expression giving #name? error, also used brackets around query name but not working.

    I try another method (i think may be it caused to corrupt the form anytime) in which i put the query as subform in main form where i need to display value.

    now the main Form"Account" have two subforms like "Transcations" and "GrandTotalQuery".

    then I refer the txt box (control source property) in main form to subform "GrandTotalQuery"s Balance Field. (like this:=[Forms]![Account]![GrandTotalQuerysubform].[Form]![Balance])
    which is working well.


    please suggest me which method is better

    i am posting my db.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I am traveling for the holiday and working on a Mac, so no Access here. I'll check the sample when I'm on a PC with Access on it. Someone else may spot the problem in the meantime.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Back from vacation. I put a textbox on the form with a control source of:

    =DLookup("[Balance]", "GrandTotalQuery")

    and it returned the same -321 that your subform method does. You can use either but the subform method is a little "heavier" because of the subform.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Unbound form example
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-24-2010, 12:25 AM
  2. Replies: 5
    Last Post: 08-13-2010, 07:26 PM
  3. Where Condition - form error
    By catat in forum Forms
    Replies: 5
    Last Post: 07-15-2010, 07:40 AM
  4. Replies: 0
    Last Post: 05-09-2010, 08:43 AM
  5. Using a form to apply a condition to a Query
    By JeepWidow in forum Forms
    Replies: 0
    Last Post: 12-22-2008, 10:29 AM

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