Insert data using a query?

L

Lloyd

I'm not sure if what I'm asking is even possible but here goes. I have a
table that contains employees and the company they work for. I have created
a query on that table to identify those employees who dont list their company
based on their employee id number. Example, employees with an ID number of
2000 - 39999 belong to a specific company, so I use the query to find all
employees with that ID number range and is null for the company name.

Now my problem. I want to use the query to update their company name, since
I know that all employees with an ID number of 2000 to 39999 belong to a
specific company I want to utilize the query to place the company name into
the Company field which is currently null. Can I do this in the query or if
not, how can I use the query and some VBA to give each person who matches the
query the same company name.

thanks!
 
M

Mike Painter

Lloyd said:
I'm not sure if what I'm asking is even possible but here goes. I
have a table that contains employees and the company they work for.
I have created a query on that table to identify those employees who
dont list their company based on their employee id number. Example,
employees with an ID number of 2000 - 39999 belong to a specific
company, so I use the query to find all employees with that ID number
range and is null for the company name.

Now my problem. I want to use the query to update their company
name, since I know that all employees with an ID number of 2000 to
39999 belong to a specific company I want to utilize the query to
place the company name into the Company field which is currently
null. Can I do this in the query or if not, how can I use the query
and some VBA to give each person who matches the query the same
company name.

I assume you are using the query builder, if so just change the type to
"Update" and add the values you want. The company ID would be a better
choice.
 
J

Jeff Boyce

Lloyd

From your description, you have ... a spreadsheet! If you know the ID
number (range), it sounds like the [Company] is also known. Why would you
need to store that info twice?

More info, please...

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.
 
K

KARL DEWEY

BACKUP DATABASE BACKUP DATABASE

Create a table like this --
Number-name --
Start End CompName
2000 39999 Bill's Park
40000 69999 Sam's Field

UPDATE YourTable SET YourTable.CompName = [Number-name].[CompName]
WHERE YourTable.EmployeeID Between [Number-name].[Start] AND
[Number-name].[End];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top