Results 1 to 4 of 4
  1. #1
    CoachBarker is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    17

    Looking for help with an expression

    I have a simple search query I am using in Access 2003 and running in a vb.net appliction. For most of the time I can manipulalte what is shown in a form field based on 1 or 0(Yes or No). But in one spot I return a dataset to a DataGridView and can not get the Yes or No value I am looking for. So instead of writing a lot of code I would just like to add an expression to the query.



    The last field is an integer and I would like to add an expression that if tblCustomers.Active = 1 then CurrentlyRenting 0 Yes else CurrentlyRenting = No. From the expression column I can get the data I need.

    Code:
     
    SELECT tblCustomers.CustomerID, tblRentals.RentalID, tblCustomers.FirstName AS [First Name], tblCustomers.MiddleInitial AS MI, tblCustomers.LastName AS [Last Name], tblRentals.StorageShedID AS [Unit Number], tblStorageUnits.BuildingNumber AS [Building Number], tblCustomers.Active, IIf([Active]=1,"Yes",IIf([Active]=0,"No")) AS CurrentlyRenting
    FROM tblStorageUnits INNER JOIN (tblCustomers INNER JOIN tblRentals ON tblCustomers.CustomerID = tblRentals.CustomerID) ON tblStorageUnits.StorageShedID = tblRentals.StorageShedID
    WHERE (((tblCustomers.LastName)="carinci"))
    ORDER BY tblCustomers.FirstName;
    Just came up with this and it seems to work. Any suggestions?
    Thanks
    CoachBarker
    Last edited by CoachBarker; 10-09-2010 at 05:28 PM. Reason: query example

  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,521
    A little simpler:

    IIf([Active]=1, "Yes", "No")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    CoachBarker is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    17
    Thanks, always seems to be a simpler way.

  4. #4
    CR08RTS is offline Novice
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Posts
    3
    hi, i need help regarding what expression i need to type into the expression builder.
    i have created a query that has calculated the age from the date of birth. in my table i have the 'date of birth' field then created the query with the formula;
    Age: DateDiff("yyyy",[Date of Birth],Now())+int(format(Now(),"mmdd")<Format([Date of Birth,"mmdd"))
    to automaticaly calculate the age. the problem now lies with the fact i want to continue building my table but need to add the calculating 'Age' field into the table first. i no i need to add a calculating field in the desig view option of my table but the question is: I DO NOT KNOW WHAT EXPRESSION I NEED TO ADD?

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

Similar Threads

  1. Expression value
    By KWarzala in forum Reports
    Replies: 0
    Last Post: 06-15-2010, 12:35 PM
  2. need help, expression is too complex?
    By ice673 in forum Queries
    Replies: 5
    Last Post: 02-15-2010, 09:03 PM
  3. Simple Expression
    By Bridgid in forum Queries
    Replies: 7
    Last Post: 06-17-2009, 09:07 PM
  4. What's wrong with this expression
    By tallroger in forum Access
    Replies: 1
    Last Post: 05-05-2009, 04:00 PM
  5. Help With an expression
    By kylem4711 in forum Queries
    Replies: 2
    Last Post: 04-23-2009, 01: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