Need query to fill in missing data on table

Hi there-

I am using Access 2003. Here's what my table looks like:


Name		ID		Company		Cost
John Smith	              1234		Phil's Towing	$84	
John Smith					                $94
John Smith					                $104
John Smith					                $151


Presumably, I need a make table query that will fill in the ID and Company 
data in each row to make it look like this:

Name		ID		Company		Cost
John Smith 	1234		Phil's Towing	$84	
John Smith	                1234		Phil's Towing	$94
John Smith	                1234		Phil's Towing	$104
John Smith	                1234		Phil's Towing	$151

Any help is appreciated. Thanks. 
0
Utf
1/5/2010 6:53:01 PM
access 16762 articles. 2 followers. Follow

2 Replies
1998 Views

Similar Articles

[PageSpeed] 27

Check Access HELP for more information about queries.

A "make table" query creates a new table.  An "update" query updates values 
in an existing table.

Before creating/running a query that changes values, be sure you've made a 
backup of the file!

Regards

Jeff Boyce
Microsoft Access MVP

-- 
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"fgbdrum" <fgbdrum@discussions.microsoft.com> wrote in message 
news:56E89730-E5F0-4AC2-9C9E-35E95A3E2EFC@microsoft.com...
> Hi there-
>
> I am using Access 2003. Here's what my table looks like:
>
>
> Name ID Company Cost
> John Smith               1234 Phil's Towing $84
> John Smith                 $94
> John Smith                 $104
> John Smith                 $151
>
>
> Presumably, I need a make table query that will fill in the ID and Company
> data in each row to make it look like this:
>
> Name ID Company Cost
> John Smith 1234 Phil's Towing $84
> John Smith                 1234 Phil's Towing $94
> John Smith                 1234 Phil's Towing $104
> John Smith                 1234 Phil's Towing $151
>
> Any help is appreciated. Thanks. 


0
Jeff
1/5/2010 8:06:58 PM
You can execute an update query which looks up the maximum ID and Company
values for each name and updates the non-Null ID and Company columns, e.g.

UPDATE  [YourTable]
SET [YourTable].[ID] =
DMAX("[ID]","[YourTable]","[Name] = """ & [Name] & """"),
[YourTable].[Company] =
DMAX("[Company]","[YourTable]","[Name] = """ & [Name] & """")
WHERE [YourTable].[ID] IS NULL
OR [YourTable].[Company] IS NULL;

However, the resulting table is not correctly normalized as it contains
redundant Name and Company columns.  You should then create an additional new
table, Contacts say, with Columns ID, ContactName and Company making ID its
primary key.  Then insert rows from the existing table into it with an
'append' query:

INSERT INTO [Contacts] 
([ID], [ContactName], [Company])
SELECT DISTINCT [ID], [Name], [Company]
FROM [YourTable];

Once you are happy that the new table is correctly populated with one row per
'contact', you can delete the Name and Company rows from the original
'YourTable' and create a relationship between the tables on the ID columns,
enforcing referential integrity and cascade updates (but probably not cascade
deletes).  The redundancy has now been eliminated, and your tables are
normalized and therefore protected from the risk of inconsistent data which
redundancy makes possible.

Note that I've used ContactName as the column name, not Name.  This is
because Name is a built in property in Access and should therefore be avoided
as a column name.

Ken Sheridan
Stafford, England

fgbdrum wrote:
>Hi there-
>
>I am using Access 2003. Here's what my table looks like:
>
>Name		ID		Company		Cost
>John Smith	              1234		Phil's Towing	$84	
>John Smith					                $94
>John Smith					                $104
>John Smith					                $151
>
>Presumably, I need a make table query that will fill in the ID and Company 
>data in each row to make it look like this:
>
>Name		ID		Company		Cost
>John Smith 	1234		Phil's Towing	$84	
>John Smith	                1234		Phil's Towing	$94
>John Smith	                1234		Phil's Towing	$104
>John Smith	                1234		Phil's Towing	$151
>
>Any help is appreciated. Thanks.

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access/201001/1

0
KenSheridan
1/5/2010 10:30:47 PM
Reply:

Similar Artilces:

Importing spreadsheet to a table from a button?
We recieve information weekly and sometimes more frequent then that. I have a access database set up with a table, queries and reports. What I would like to do is instead of having to manually go in and import the table to make it more user friendly to the folks that don't know how to use access that well. I figure this will have to be done through code to call the worksheets, but I would like to create a button on a form that when selected it will automatically import the spreadsheet directly to the table. If it has to call the wizard that still would not be as bad and navigating throug...

Not sure if Excel can do what i need
Hello all, I am obviously a new user to excel. I have a psychological assessmen that needs to be computerised for ease of use in obtaining results. Here is what i would like to happen. I have 28 questions with fiv Likert scale options(0-4) for answers. Each question addresses 1 of different personality traits. So questions 1, 6, 8, 22 look at anger. Where as questions 2, 9, 28 look at happiness. What i would like is fo excel to group the answers and give me the total number for each trait. Then based on that number, give out a prewritten (which i would provide result of the assessment. ...

Extracting Data #2
Dear All, I need a help on data extracting... I have a data abt 12 col and 40 rows with header in each col. the header like --- Inv no, Inv Dt, Customer Name, amount, chq no Chq date etc.... there are mutiple records (ie. rows) for a customer, i want to lis all the records / rows pertining to a customer and make report in a diff worksheet. I can do this using advance filter, but if i change the the custome name resepective rows will not get changed dynamically, again i have to do the whole process of advance filter.. cud u plz suggest same other method so that records are dynamicall chan...

Need Min Value from Row and Heading Value that Corresponds to it.
I have a table that looks somewhat like this w/o the *'d headings: h1 h2 h3 h4 h5 h6 h7 *Min Price *Heading $5.00 $6.00 $3.00 $4.00 $9.00 $1.00 $9.00 $1.00 h6 $3.00 $6.00 $8.00 $65.00 $9.00 $2.00 $4.00 $2.00 h6 $4.00 $9.00 $5.00 $7.00 $1.00 $2.00 $8.00 $1.00 h5 $9.00 $7.00 $6.00 $3.00 $9.00 $8.00 $2.00 $2.00 h7 $7.00 $8.00 $9.00 $7.00 $9.00 $8.00 $8.00 $7.00 h1 I have several SKU's with various price contract/programs. I want to find the best price in one cell and the heading that would correspond to that cell in another. I was trying to do this with an expression ...

How do I plot Excel data on a floorplan?
I'm trying to find a way to plot data from an Excel worksheet on a floorplan diagram. The data reflects room assignments for a hospital, so some data stays the same for days while other data changes on a twice a day basis. I want to enable someone to be able to enter the data on the worksheet and have excel output the names, etc in the proper room assignments on the floorplan automatically. The users could then print this floorplan to locate the assignments more easily. I can either scan a hardcopy of the floorplan, or I have access to Visio so I could also quickly construct a d...

Excel need help
I have 2 columns a and b . a contains payment b contains balance. I have the entire col b with the formula. my ? is when the balance appearsin b it is in all the cells in that column.I only want it in the used ones, not the unused ones:( example $270.00 16,730.00 $270.00 16,460.00 $100.00 16,360.00 $300.00 16,060.00 $270.00 15,790.00 15,790.00 15,790.00 15,790.00 15,790.00 15,790.00 this 15790.00 is in col b...not a...I want no bal in unused cells -- fiftieslady ------------------------------------------------------------------------ fiftieslady's Profile: http://www.excelforum.co...

How do I Excel formula =LEFT(A2,LEN(A2)-3) in an Access Query
I need to delete the last 12 characters (phone number) from a field that contains names and phone numbers. Lou Are you asking how to do this in MS Access? If so, take a look in Access HELP re: Mid() function and Len() function. Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein does not constitute endorsement thereof. Any code or pseudocode included in this post is offered "as is", with no guarantee as to suitability. ...

Need Help Linking Sheets
How can I link 2 pages without using the actual sheet as a reference? In other words, can I have two sheets linked by Identifying the same exact names one on each sheet? ...

Excel newbie needs help from math wiz (poker related)
I want to create a Excel workbook that will help in specific poker situations. Short version: I want to be able to calculate how often my opponent will need to fold for an all-in raise to show a positive expectation. Explanation: In poker you can win a hand by having the best hand at the end OR getting your opponent to fold. A common situation comes up where you have a "drawing hand" and face a bet by your opponent. In this situation you know you are currently behind in the hand, but have a chance to win if you catch some of your "outs" (cards that will give you th...

Macro help needed........
How do I sort a particular column in ascending order and change the pag setup to landscape and margins to 0.25 using a macro code ? does anyone have a macro code for this ????? -- Message posted from http://www.ExcelForum.com Hi you have already received some answers in your previous threads please don't multipost! -- Regards Frank Kabel Frankfurt, Germany > How do I sort a particular column in ascending order and change the > page setup to landscape and margins to 0.25 using a macro code ? > > does anyone have a macro code for this ?????? > > > --- > Me...

text boxes filled with color
When I fill any text bos with color while creating anm e-mail publication, the text boxes are converted into images instead of text, thus making my file size bigger. How to change this? Lavanya <Lavanya@discussions.microsoft.com> was very recently heard to utter: > When I fill any text bos with color while creating anm e-mail > publication, the text boxes are converted into images instead of > text, thus making my file size bigger. How to change this? There is no way to change it. This is the way Publisher works. Publisher is not designed for outputting small HTML code. --...

Need to test a mobo
I had a power surge about 3 weeks ago - lost a drive, now making ticking noises. I had another two drive that seem to work sporadically now. So, I thought it might have been my power supply. Bought a tester and found out that all seems well. Next, I bought a new hard drive and found that it was also acting up - making noises like whirring up and down (like the other drives I thought were dead). So I am starting to wonder if it is my mobo - but how can I test this out? I am using a dual boot - Win XP and Win 7 - both drives work and don't work. Up and down. Right now my Win7 ...

Lost formatting in Query
I have a query based off of a table, with a subdatasheet pulling from a separate table. I've been using this system for approximately 3 years with no problems. However, within the last few months, I've had a problem with the formatting being lost each morning. I'm constantly having to re-insert the subdatasheet and re-size all my columns that have gone back to the default width. I've never had this problem until recently. My solution so far has included a compact and repair, and to re-design the entire query from scratch. Neither have solved the problem. As another...

Query to update new fields in table
I added two fields to a table a date field and a Day field. The table already had approximately 40,000 records. Is there a query I can use that will add the date and day to the already existing data. I know moving forward I can get update with an append query. An Update query will update existing fields. Just choose the fields you want to update, and put the data in the row marked Update to, and you are good to go. CS wrote: > I added two fields to a table a date field and a Day field. The table > already had approximately 40,000 records. Is there a query I can use that >...

how to bind an query to a gridview programmatically?
Hi, i want to bind programmatically the records of a select query to an existing gridview. I can get the records via dtreader, but i don't know how to get them into the gridview (which is created in the aspx file) Thanks Luc My attempt: connectionstr = ConfigurationManager.ConnectionStrings("myconn").ConnectionString.ToString() connection = New SqlConnection(connectionstr) comd = New SqlCommand() comd.Connection = connection comd.CommandText = "select field1 from table1" connection.Open() dtreader = comd.ExecuteReader If dtreader.HasRows Then...

Data Lables, series and Scatterplots
Is there any way to get excel scatterplots to recognize a third column (or row) as a series for a scatterplot? FOr example I have data as: Sequence Long Lat 1 49.12 28.05 2 49.17 28.34 3 49.5 28.48 4 49.17 28.36 I would like to plot Long(itude) as X axis and Lat(itude) as Y on scatterplot (which I can do). But I would also like to identify the sequence number fopr each point. I thought I could do that by getting the Sequence numbers to represent a series, but can't sseem to get that in a scatterplot. Is there any other chart...

Help needed
is there anyway you can see what links to other workbooks are associated with the workbook you have open. The problem i am having is when i open the workbook in question a message appears and states "The workbook you opened contains automatic links to information in another workbook. do you want to update this workbook with changes made to the other workbook" Yes....... No. if i click No the workbook opens, however if i click Yes the workbook just hangs and i have to go into task manager to shut down the system. I can only assume that there is a problem with one of the links....

Need help on this....thanks
I have an Excel worksheet which stored a survey outcome of over 1200 members. There are over 30 questions in the survey and the first column captured the member ID. The problem is 3 of the survey questions that allow multiple answers, instead the answer for those three questions are captured in seperate column, the answers are stored in a single column and it makes it very difficult to analysis those result. As a result I created addittional columns depending on the total number of the answers available for that question and assign the result manually to that column. It is very time consuming ...

I need Help
I have a random popup that i cant stop,when it does come up it seems to know what i was looking at,like when i was looking for registry cleaner it popped up and showed me one,any help would be great. On Jan 22, 6:57=A0am, Larry <La...@discussions.microsoft.com> wrote: > I have a random popup that i cant stop,when it does come up it seems to k= now > what i was looking at,like when i was looking for registry cleaner it pop= ped > up and showed me one,any help would be great. To eliminate questions and guessing, please provide additional information about your sys...

need help badly
How do you print ole objects.. Thanks lachanda -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200710/1 On Wed, 03 Oct 2007 18:13:40 GMT, "misschanda via AccessMonster.com" <u36612@uwe> wrote: >How do you print ole objects.. >Thanks >lachanda What *kind* of OLE objects? Many of them are binary blobs (such as programs) which are inherently not printable. More details please! John W. Vinson [MVP] ...

Ones in pivot table
Hello, I import my pivot table data from an external data source (MS Access query) and it displays like this: http://www.geocities.com/blinton25/Count.jpg instead of showing values. If I double click on any of "2's", a new worksheet is generated showing me the actual values. How do I make the values show like this: http://www.geocities.com/blinton25/Count2.jpg Brenda, Post a small table of your data: you probably need to change what data you are using in the pibot table, and change from count to sum for the fields. HTH, Bernie MS Excel MVP "Brenda Love" &...

Stuck in review and need to be in design.
I am using Visio 2007. I need to complete the diagram that I have been working on and I hit the review key by mistake. How do I get back to the design screen? On Wed, 4 Nov 2009 16:14:01 -0800, cameron <cameron@discussions.microsoft.com> wrote: >I am using Visio 2007. I need to complete the diagram that I have been >working on and I hit the review key by mistake. How do I get back to the >design screen? menu Tools -> Track Markup and then close the Review window. -- Regards, Paul Herber, Sandrila Ltd. DFD/SSADM for Visio http://www.visio-dfd.sa...

Missing Text #5
Hello, I have a problem with Outlook XP (2002) that I can't find a solution for. When this particular user receives a reply to an email she sent, the frist couple of lines of the reply text will appear in the auto preview (the preview in the message listing in the inbox) but when she opens the message itself by double clicking it, that reply text is missing. I've updated Outlook to SP3 and even tried reinstalling it once. Does anyone know of a fix for this? Thanks, Rod ...

Need Help Despertly!
I am in a desperate situation. I had to reformat my hard drive. Prior to do this, I copied my entire User Profile to another drive. I can now access my User Profile information from Windows Explorer. Now that I installed Microsoft Outlook, I do not see any of my Contacts. I need to restore my Contacts to the new Outlook installation. Again, I did save my entire "User Profile" from my previous installation of Windows 2000 Professional. I just do not know how to access my Contact information from Outlook that included addresses and phone numbers and such. Any help would be greatly appr...

Plug in needed
Looking for an Outlook plug in which, on reply to a e-mail, will:- a) allow selective quoting only, and b) not top quote. Anything around at all? Much to my horror (sorry guys) the Boss wants us to use Outofluck at work! -- On the carpool lane lane to Nirvana. John Phillips <flatulentdingo@deadspam.com> wrote: > Looking for an Outlook plug in which, on reply to a e-mail, will:- > > a) allow selective quoting only, and > > b) not top quote. > > Anything around at all? The best Outlook adjunct I've found for quote handling on replies is Outlook-Quotef...