Ask Experts Questions for FREE Help !
Ask
    polaketta's Avatar
    polaketta Posts: 6, Reputation: 1
    New Member
     
    #1

    Apr 10, 2009, 05:56 PM
    Creating simple queries in Access 2007
    Hello there. I'm a student in Information Technology Management and am working on an assignment for Access 2007. I ran into some issues with creating my queries and cannot seem to get the right results. Can anyone help?
    Scleros's Avatar
    Scleros Posts: 2,165, Reputation: 262
    Hardware Expert
     
    #2

    Apr 10, 2009, 07:11 PM
    Yes, someone, somewhere can help. However, we cannot, as you didn't provide any information about your issues. There are many many questions to be answered here. Those first requiring information extraction (like pulling teeth) tend to be passed over.

    *begin extraction... *
    polaketta's Avatar
    polaketta Posts: 6, Reputation: 1
    New Member
     
    #3

    Apr 10, 2009, 07:19 PM

    I have a simple database. I need to create a query that will show items that yield the most revenue. I have fields with ItemName, ItemType, PricePerItem and DailyAverageSold. I need to create a calculated field showing "DailyAverageSold * PricePerItem".
    Scleros's Avatar
    Scleros Posts: 2,165, Reputation: 262
    Hardware Expert
     
    #4

    Apr 10, 2009, 07:24 PM
    What did you try?
    polaketta's Avatar
    polaketta Posts: 6, Reputation: 1
    New Member
     
    #5

    Apr 10, 2009, 07:29 PM

    I have put all these headings into fields. Then I added a new field called - Expr1: [RevenuePerItem] - and in the criteria put in the formula [DailyAverageSold]*[PricePerItem]. But when I run the query - I get the pop up 'Enter Parameter Value' - I don't know what to do with this.
    Scleros's Avatar
    Scleros Posts: 2,165, Reputation: 262
    Hardware Expert
     
    #6

    Apr 10, 2009, 07:52 PM
    Quote Originally Posted by polaketta View Post
    then I added a new field called - Expr1: [RevenuePerItem]...I get the pop up 'Enter Parameter Value'...
    That is the behavior that normally results when there is a reference Access cannot resolve typically caused by a syntax error. In this case the reference is [RevenuePerItem] which doesn't exist in your table. The syntax for calculated fields is: FieldName:Formula placed in the "Field:" field in the query design.

    Quote Originally Posted by polaketta View Post
    ...and in the criteria put in the formula [DailyAverageSold]*[PricePerItem]
    The "Criteria:" field is the wrong place to put the correct formula. Using the syntax above, use this formula in the "Field:" field in the query design. This is covered in Access Help (F1) > Queries > Introduction to queries > "Make calculations based on your data" subtopic. The help is your friend.
    Attached Images
     
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #7

    Apr 10, 2009, 08:18 PM

    As Scleros said, you put the calculation after the Alias in the top row of a blank column. The next step is to sort that column in descending order so the that top revenue items are on top.
    polaketta's Avatar
    polaketta Posts: 6, Reputation: 1
    New Member
     
    #8

    Apr 10, 2009, 08:25 PM

    Ok - thanks - the query is starting to look right. My next problem. I need to include criterion to select text. I need to tell it to select either a 'yes' or 'no' from a field. I also need to select 2 categories - in my specific query they are items are are 'bread' and 'pastry'
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #9

    Apr 10, 2009, 08:35 PM

    Please review the guidelines on asking for help with homework that can be found here:

    Ask Me Help Desk - Announcements in Forum : Arts & Literature


    We will NOT do your homework for you. You need to show us what you have done (post the SQL from the query) and we can critique your work.
    polaketta's Avatar
    polaketta Posts: 6, Reputation: 1
    New Member
     
    #10

    Apr 10, 2009, 09:10 PM

    Sorry - I didn't mean to come across as trying to get you to do my work for me. I don't know how to post SQL. And the Help in access is not that 'friendly'. I find that it just gives too much information and it's vey difficult to figure out. I was able to get the answers by putting - RevenuePerItem: [PricePerItem]*[DailyAverageSold] - into the field. That showed up correctly. I have values as Yes and No in the 'MadeInStore' and get the error of mismatching data. I've also tried to put the 'yes' in the criteria but when I run the query it shows up as -1 or 1.
    Scleros's Avatar
    Scleros Posts: 2,165, Reputation: 262
    Hardware Expert
     
    #11

    Apr 10, 2009, 10:29 PM
    Quote Originally Posted by polaketta View Post
    And the Help in access is not that 'friendly'...
    Yes, it sucks, but unless you go buy an Access book, it's the only thing you've got. And I don't think you learn anything productive about how to use Access for real applications spending all your time reverse engineering the syntax through trial and error. I've been down that road and I still get frustrated every time I do something in Access since I don't use it everyday.

    Quote Originally Posted by polaketta View Post
    I have values as Yes and No in the 'MadeInStore' and get the error of mismatching data. I've also tried to put the 'yes' in the criteria but when I run the query it shows up as -1 or 1.
    Data in Access is of some type. You set the type in the table design - number, text, etc. There is a Yes/No type that equates to a True/False or BOOLEAN data type that is common in programming languages. Your Yes/No values could also be implemented as "Yes" and "No" strings of type text. When specifying criteria, the type of the selectors in your expressions should match the type of the values in the data or you can get funky results. Yes/True/On and No/False/Off are equivalent when entered without quotes and can be used for BOOLEAN expressions.

    Posting SQL simply means posting the SQL statements such "SELECT Table1.ItemName FROM Table1 WHERE (((Table1.ItemName)="Widget"))". This format for the query is shown via SQL View in Access. You may not have reached the point in the class where SQL notation is discussed. The Design View of Access is supposed to be a simpler way to construct queries than having to type in the SQL directly and it generally is as long as one gets the @#$%^ syntax correct and the expressions in the right boxes.
    polaketta's Avatar
    polaketta Posts: 6, Reputation: 1
    New Member
     
    #12

    Apr 10, 2009, 10:48 PM

    Thanks for all the help. Since this assignment is 5% of the total mark, I've decided that I'll settle with part marks for what I believe could be the correct answers (for which I put the calculation in the 'field' lines). I'll give up now. Funny how Access has changed since 2000 when I first learned it in college (and the Access book came with the course back then). Now everything is online - and here I thought that it would be easier! Ha! Anyway - thanks again. It's been a learning experience for me. Until today, I never thought to look for a website like this. Maybe we'll connect in the future on some other thread. Take care.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #13

    Apr 11, 2009, 05:39 AM
    In Query Design mode, you access the SQL view of your query. Just copy and paste. As to the Access Help being friendly, I think it very useful. I use it frequently to remind me of syntax.

    But I can't believe you were given a school assignment without first having query design explained. Or you were at least given handouts that explained it.

    Quote Originally Posted by polaketta View Post
    I have values as Yes and No in the 'MadeInStore' and get the error of mismatching data. I've also tried to put the 'yes' in the criteria but when I run the query it shows up as -1 or 1.
    Did your instructor explain datatypes to you? That would be taught before queries, as part of table design. You apparently have a Yes/No (Boolean) field. Such fields contain the value -1 for Yes and 0 for No. If you enter "Yes" (with the quotes) as your criteria, you are comparing a text datatype with a Boolean datatype. Hence the mismatch. You can use Yes (without the quotes) or True or On (No, False and Off) or you can just use -1 and 0.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Create weekly,monthly,quarterly and yearly queries in access 2007 [ 1 Answers ]

Hi everyone. I have designed a database that keeps a record of users 's details as they enter and leave the library.Examples of this fields are: VisitorID,Name,TimeIn,TimeOut,DateOfVisit,NatureOfVisit All the above are recorded in a table called visitDetails. I have two tables and the...

Some important queries regarding 2007 tax (H1B). [ 3 Answers ]

I have stayed in US on and off from 2004. Here are my stay details : 2004- 153 days, 2005 - 283 days, 2006 - 284 days, 2007 - 256 days My annual gross income is in range of $70K for 2007. a. I think I would be resident alien, please confirm?

Creating a relationship in Access [ 1 Answers ]

I am trying to link Customer Contact Information to numerous orders they have placed. I have created the relationship, but not sure on how to creat the form view to correspond the two relationships. Any insight would be very helpful.

Access Queries [ 1 Answers ]

Am new and very happy to be in this forum. I have an access database which comprises of many tables. My problem is I am tryng to develop a query possibly in design view which needs to use this condition if storagedays>7 then storagedays=storagedays-7. unfortunately I haven't done it before.....


View more questions Search