Information from 2 tables

Dowsey1977

Board Regular
Joined
Apr 6, 2004
Messages
185
I have 1 table with a load of person data in it, and one with that will be populated with a load of dates. The person one has data in it, but the dates one is empty.

How do I create a query that will get some information from the person data, so all names are listed, and then all the information, although blank, from the dates table?

Any help greatfully received.

Simon
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Simply create a new query, selecting both tables, and then link the two tables together (they must have a field in common to link them). Then select the fields from each table you want to display in your query.

If you go to Access help and type in "Create a Query", you will see a lot of information that will assist you in writing queries.
 
Upvote 0
Ok...managed to get that to work. Now that I have created this query, I have a form linked to it. So when I add information into this it should update the source table??

What I want to do now is add formulas into some of the fields. So I have 1 date field (called date 1 for simplicity) and there are a load of other date fields and I want the date to be automated by running calculations based on Date 1. So for example, I want the date in Date 2 to be 2 weeks prior ot Date 1, so I want to add in =Date-14. But I also want this information to be auto-updating the source table.

I tried putting in an expression in the BeforeUpdate section of properties, but the Date 1 will already be populated from the source table so won't be updated in this form.

Hope that is clear!
 
Upvote 0
So when I add information into this it should update the source table??
Yes, except for in special cases where you are using non-Updateable Query or Form Types (in which case it will tell you you cannot add/change data).
So for example, I want the date in Date 2 to be 2 weeks prior ot Date 1, so I want to add in =Date-14. But I also want this information to be auto-updating the source table.
You can update tables using the Action Query called Update Query (see "Create an action query" in Access help). HOWEVER, if the Date2 field (and/or other fields) are solely dependent upon other fields in your table, it is considered poor design to store this information in a table (and your table is not considered to be Normalized -- the goal of all good database desgins).

If certain fields can be calculated from other fields, it is highly recommended that these fields are simply calculated fields stored in queries and not stored in the source table.

Why? Because if Date2 is dependent on Date1, if Date2 is a calculated field in a query, any change to Date1 will automatically update the Date2 calculated value. However, if you are storing Date2's value in a table instead of a query, any change to Date1 will NOT automatically update Date2; you will need to update it manually, or develop another process to update it. Hence, the integrity of your data can be easily compromised.

Remember, all Forms and Reports can use Queries as their sources just as easily as they use Tables, so it is not necessary to store calculated values in tables if they can be calculated in queries.
 
Upvote 0
Ok....so, the form is based on the query that gets the information from 2 tables. I have taken out the current control souce and simply added in the formula. Can the result of thisbe shown in the query??
 
Upvote 0
Ok....so, the form is based on the query that gets the information from 2 tables. I have taken out the current control souce and simply added in the formula. Can the result of thisbe shown in the query??
I'm not sure I understand what you are saying. You WANT the query to be the Control Source of the Form; and you want the formula to be a calculated field in your query, not a direct calculation in your form.
 
Upvote 0
What I have done so far is use the query as the source for the form, and then in the field row of the query done a load of expressions that do the calculations...is this right so far?

The only problem with this way is that the headings are then Expr1, Expr2....which is less than ideal!!
 
Upvote 0
Yes, you are on the right track.

You can name your expressions anything you want by prefacing them by a name and a colon, i.e. MyCalc: ...

For the ones that are already written, go back into the expression builder, highlight the name Expr1 and change the name to whatever you want.
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,250
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top