IIf statement with dates

So, in your opinion, (remember, this is for my family business, not just for fun) what would you do? I am trying to make the "how much we payed for gas" field become automated, just one thing to make entering data easier. because otherwise we would have to do the math of what the gas price is times how many miles...pretty much what im doing now, but without human intervention. Thanks once again.
 
I have read through the thread and realise , I think, that you just a table and nothing else. You are doing the calculation in a field in the table, is that correct?

In Access as in any RDBMS tables are for storing data, that data is input via a form, it is queried by a Query where selection, filtering and calculations are done, in the main, and the final output is viewed in a form or report which uses the query as its source.

To future proof your system and learn to do things properly this is what you should aim for.

Brian
 
So what is the correct way that I should do it? Just create a bunch of tables for each thing that I would calculate by?
 
Yes is the short answer - To start with create a simple table with 2 fields FuelYear, FuelRate.
Populate the table with the data you have. The year field should be a date field and personally I would set it to the first date of the year 1/1/2012.
 
I'm thinking ive been going at using access all wrong. I use the tables as how I view, edit, and add information. But it looks like I should use tables to edit, query to view, and tables to add. And it also looks like I shouldn't shy away from having lots of tables for everything. And have query to view it all. Or forms to view. Thing is im used to having all the info I can get into one table, and now im thinking (if thats the way to go) that i should have tables for really each thing, because I am used to the excel way of thinking, not access. Is anything im saying making sense, and im a correct?
 
I use the tables as how I view, edit, and add information. But it looks like I should use tables to edit, query to view, and tables to add.
Forms to add. Otherwise, correct.

And it also looks like I shouldn't shy away from having lots of tables for everything.
You have a table for each entity you are required to model. Sometimes, you may even need extra tables to model a many-to-many relationship.

Thing is im used to having all the info I can get into one table

That's what spreadsheets are for. If Access was like Excel, we wouldn't need Access because, as the kids say, there's an app for that.

Is anything im saying making sense, and im a correct?
It sounds like the mist has dispensed, and you can see clearly now.

You must google and read about Normalization. Understanding it now saves many problems later.
 
That is what our show list looks like. What would you do different? Just trying to figure out what im doing wrong is all. Thanks for all your help!
 
Last edited:
well your all here, how would I find the average of items sold? I've got a query of all my items sold last year, how would I get the highest, lowest, and average of them sold?

FYI: Its got over 40+ items, with 13k sales. I have the quantity and item. how would I get what I want from that? Danka!
 
On a train now, so can't open database on iPad, but you can look into either Domain Aggregate Functions (DMax, DMin, and DAvg). Or you can calculate Min, Max, and Avg in your queries.

Where it says Group By, you can change to a calculation method.
 
Im not getting the Dmax or stuff to work. Ill just keep researching that, in the mean time, as any one been able to look at my Ledger and give me any advice? Thanks!
 
I am trying to figure out the Average amount of items sold that I sold last year. I have a query with all my items from last year, and the quantity, but, im no sure how to tell it to get me a average of the items. I can tell it to get me a average from the quantity, but not the items. I have around 40 items, and 13K plus sales for last year. How would I go about doing this? Thanks for your answer's!

EDIT: I have lots of sales, with the quantity for each sale. I want to know, that last year I sold a average of 28 of item B. And a average of 13 of item A, etc, etc. And also the highest selling item for last year, and the lowest selling item. Thanks!
 
I scanned the thread fairly quickly and looked your database4.

It is not normalized at all. Can you give me the short version of the database, its purpose, design and current status?

Show me some code or query you are trying.

What is the biggest issue at the moment?
 
Its supposed to be for my/our family business, and that is each show we go to to sell our products. how much we made, gas price, etc, etc. Biggest issue? Just learning to use the correct items for what, I understand I should use lots of different tables for stuff, but its really hard! And annoying when I want it all on one nice, neat table to view. But thats why access has querys I guess... :banghead:
 
So what is your biggest issue right now? Is there something that is stopping your business?
If not, set this aside, and work through this tutorial. Put everything else to one side and spend an hour doing the tutorial.

You will learn why there are tables and what relationships really represent. You are in a great position to learn because--you know your business. You appear to have come from a spreadsheet background (1 table lots of columns). Database is different(many tables, lots of rows).

Once you are confident with the tutorial, post back because there are videos and other tutorials that can help you with concepts.
 
Having a small issue, I have a query, its got my items and quantity, I change the Total field in the items to avg, and the quantity to sum, but it errors, same if I change em both the avg. It says "Date Type mismatch in criteria expression" What does that mean? Thanks!
 
Looking at the database, it looks like you may need some initial tables like this, and then more to model the financial parts, as I'm not sure how they all inter-relate...


An Events table. This table will represent the many events that your business will handle/present. Not to be confused with Shows. [I've left out the Home/Away and Inside/Outside fields for now, as not sure how the work.]

tblEvents
EventID (Primary Key, Autonumber)
ShowID (Foreign Key, Number)
StartDate (Date/Time)
EndDate (Date/Time)
StateID (Foreign Key, Number)
VenueID (Foreign Key, Number)


A Shows table. Your current table contains repetitions of the same show names, differentiated only by date. This suggests you have/perform the same shows available for different times. Therefore, we need to model these...and we don't need to put the date in the show's name, as the date(s) of the show will be captured in the Events table.

tblShows
ShowID (Primary Key, Autonumber)
ShowName (Text)
ShowTypeID (Foreign Key, Number)

A Show Type table that will determine, as the name suggests, the type of show that it is. We keep this in a separate table as, although it's related to the Show, it's actually an entity in its own right. [This is actually what you called Venue type, but based on the descriptions, it doesn't really described the venue as much as it does the show.]


tblShowTypes
ShowTypeID (Primary Key, Autonumber)
ShowType (Text)

A States table. You could just have a list hardcoded into your database (as you do), but I think it's always better to have the data in a table where its manageable. Plus, should you expand (into Canada, say), then the hardcoded 50 state limit becomes an issue of design, rather than one where you can just add a new Canadian state into the table. I've made a field for key, one for the two letter code, and one for a full description.


tblStates
StateID (Primary Key, Autonumber)
StateCode (Text)
StateName (Text)

A Venues table that will record information about the venues where events will take place. Always useful to maintain contact details, etc.


tblVenues
VenueID (Primary Key, Autonumber)
VenueName (Text)
Telephone (Text)
Email (Text)
Address1 (Text)
Address2 (Text)
ZipCode (Text)

I've not gone to the extent of thinking about fields like Vendors, People, etc, as I'm not sure what they are (vendor capacity? venue capacity?)

You may then want to think about your tables. Personally, I'd have a table for Tables, with each table that you have individually logged/itemised. Not sure if you also have chairs or other furniture, which may also need considered. For the purposes of this, and to add a bit of complexity, let's assume not....



tblTables
TableID (Primary Key, Autonumber)
TableName (Text)
TableSize (Text)
TablePrice (Currency)

Now we need a way to link these tables to our event...but this is a many-to-many relationship, so we need a junction table for Tables to Events...


tblTablesToEvents
EventID (Primary Key, Number)
TableID (Primary Key, Number)


I see we have a field for Vehicles, but it appears just to be a quantity...let's create a table to store all our vehicle information...



tblVehicles
VehicleID (Primary Key, Autonumber)
VehicleModelID (Foreign Key, Number)
ModelYear (Number)


Of course, vehicles come in all sorts of Makes and Models....so we may need fields for those....


tblVehicleMakes
VehicleMakeID (Primary Key, Autonumber)
VehicleMake (Text)


tblVehicleModels
VehicleModelID (Primary Key, Autonumber)
VehicleModel (Text)
VehicleMakeID (Foreign Key, Number)


Now, like Tables, there can be more than one Vehicle to each event, so let's capture them in another junction table for Vehicles To Events.


tblVehiclesToEvents
EventID (Primary Key, Number)
VehicleID (Primary Key, Number)

Right, now show me the money!!!

Well, you've got a lot of fields here. Not sure of how things relate, etc but looks like we need tables for Costs and Cost Types; one for Tax Rates. There's talk of Shipping, so perhaps something for Shipping Details. I wouldn't want to go further without understanding how these fields work and can be normalised.

But, reading this, do you get a better understanding of why we split out your single 'MASTER-Show-List' table into many more tables?

For now, rather than getting in a twist about averages, maxes, and mins, get your tables in a good working order.
 
quick question, when it says for instance, ShowID (Foreign Key, Number) and ShowID (Primary Key, Autonumber) do I just have it get the ShowID, or the show name? And if so, how would some one know what the ID is to the ShowName?

also, lol, you said
I'd have a table for Tables, with each table that you have individually logged/itemised. Not sure if you also have chairs or other furniture, which may also need considered.
That is like our table size for each show, 10X10 booth, its really booth size, not table.

Also, what is the difference between "Event" and "Show??"
 
Last edited:

Users who are viewing this thread

Back
Top Bottom