473,386 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Stumped on update query between tables with no Join fields

I have two tables related to sales transactions and assigned areas.

The tblSalesArea has SalesAreaID an autonumber
StartZip, Text
EndZip, Text

The tblSales has many fields detailing all the sales. The two fields of
concern are
ZipCode, Text and SalesAreaID a number.

I need to populate the tblSales!SalesAreaID with the
tbleSalesArea!SalesAreaID
based on the zipcode being between tblSalesArea!startzip and
tblSalesArea!endzip.

This is where I am and it doesn't work. I suspect because the tables are
not joined.
I could open two datasets and do it pretty easily in code but that would be
slow.
Any Ideas??

Thx

UPDATE tblCentral, tblSalesAreas SET tblCentral.OwnerID =
tblSalesAreas!CompanyID
WHERE (((tblCentral.SoldToZip)>=[tblSalesAreas]![StartZip] And
(tblCentral.SoldToZip)
<=[tblSalesAreas]![EndZip]));


Jun 27 '08 #1
7 1304
rkc
KC-Mass wrote:
I have two tables related to sales transactions and assigned areas.

The tblSalesArea has SalesAreaID an autonumber
StartZip, Text
EndZip, Text

The tblSales has many fields detailing all the sales. The two fields of
concern are
ZipCode, Text and SalesAreaID a number.

I need to populate the tblSales!SalesAreaID with the
tbleSalesArea!SalesAreaID
based on the zipcode being between tblSalesArea!startzip and
tblSalesArea!endzip.

This is where I am and it doesn't work. I suspect because the tables are
not joined.
I could open two datasets and do it pretty easily in code but that would be
slow.
Any Ideas??

Thx

UPDATE tblCentral, tblSalesAreas SET tblCentral.OwnerID =
tblSalesAreas!CompanyID
WHERE (((tblCentral.SoldToZip)>=[tblSalesAreas]![StartZip] And
(tblCentral.SoldToZip)
<=[tblSalesAreas]![EndZip]));
A much better solution would be to design your tables correctly.
Are you familiar with the concept of normalization?

You have a one to many relationship between SalesAreas and zipcodes
so there should be two tables to model that. The range thing is a real
bad idea.

Your Sales table has a Zipcode field so it does not need a SalesAreaID
field. That information would already be available from the first two
tables mentioned.

Don't worry though, someone will write you a query to work with the
mess you have.


Jun 27 '08 #2
These are not really tables that have been designed in a DB. They are the
intial tables
created from reading in two distinct spreadsheets. I need to get that id
over so that I can
matchup the data in a real db.

But your comments are correct.
"rkc" <rk*@rkcny.yabba.dabba.do.comwrote in message
news:48**********************@roadrunner.com...
KC-Mass wrote:
>I have two tables related to sales transactions and assigned areas.

The tblSalesArea has SalesAreaID an autonumber
StartZip, Text
EndZip, Text

The tblSales has many fields detailing all the sales. The two fields of
concern are
ZipCode, Text and SalesAreaID a number.

I need to populate the tblSales!SalesAreaID with the
tbleSalesArea!SalesAreaID
based on the zipcode being between tblSalesArea!startzip and
tblSalesArea!endzip.

This is where I am and it doesn't work. I suspect because the tables are
not joined.
I could open two datasets and do it pretty easily in code but that would
be slow.
Any Ideas??

Thx

UPDATE tblCentral, tblSalesAreas SET tblCentral.OwnerID =
tblSalesAreas!CompanyID
WHERE (((tblCentral.SoldToZip)>=[tblSalesAreas]![StartZip] And
(tblCentral.SoldToZip)
<=[tblSalesAreas]![EndZip]));

A much better solution would be to design your tables correctly.
Are you familiar with the concept of normalization?

You have a one to many relationship between SalesAreas and zipcodes
so there should be two tables to model that. The range thing is a real
bad idea.

Your Sales table has a Zipcode field so it does not need a SalesAreaID
field. That information would already be available from the first two
tables mentioned.

Don't worry though, someone will write you a query to work with the
mess you have.


Jun 27 '08 #3
rkc
KC-Mass wrote:
These are not really tables that have been designed in a DB. They are the
intial tables
created from reading in two distinct spreadsheets. I need to get that id
over so that I can
matchup the data in a real db.

But your comments are correct.

Try replacing the bangs you have in your query with dots.
Perhaps use between as the comparison.

You're confusing referencing controls on a form with referencing
fields in a table.

Jun 27 '08 #4
"KC-Mass" <connearneyATcomcastDOTnetwrote in
news:EN******************************@comcast.com:
I have two tables related to sales transactions and assigned
areas.

The tblSalesArea has SalesAreaID an autonumber
StartZip, Text
EndZip, Text

The tblSales has many fields detailing all the sales. The two
fields of concern are
ZipCode, Text and SalesAreaID a number.

I need to populate the tblSales!SalesAreaID with the
tbleSalesArea!SalesAreaID
based on the zipcode being between tblSalesArea!startzip and
tblSalesArea!endzip.

This is where I am and it doesn't work. I suspect because the
tables are not joined.
I could open two datasets and do it pretty easily in code but that
would be slow.
Any Ideas??

Thx

UPDATE tblCentral, tblSalesAreas SET tblCentral.OwnerID =
tblSalesAreas!CompanyID
WHERE (((tblCentral.SoldToZip)>=[tblSalesAreas]![StartZip] And
(tblCentral.SoldToZip)
<=[tblSalesAreas]![EndZip]));
UPDATE tblCentral
SET tblCentral.OwnerID =
Dlookup("companyID","tblSalesAreas",
"SoldToZip between [StartZip] And [EndZip]");
--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **
Jun 27 '08 #5
Thanks very much.

"Bob Quintal" <rq******@sPAmpatico.cawrote in message
news:Xn**********************@66.175.223.2...
"KC-Mass" <connearneyATcomcastDOTnetwrote in
news:EN******************************@comcast.com:
>I have two tables related to sales transactions and assigned
areas.

The tblSalesArea has SalesAreaID an autonumber
StartZip, Text
EndZip, Text

The tblSales has many fields detailing all the sales. The two
fields of concern are
ZipCode, Text and SalesAreaID a number.

I need to populate the tblSales!SalesAreaID with the
tbleSalesArea!SalesAreaID
based on the zipcode being between tblSalesArea!startzip and
tblSalesArea!endzip.

This is where I am and it doesn't work. I suspect because the
tables are not joined.
I could open two datasets and do it pretty easily in code but that
would be slow.
Any Ideas??

Thx

UPDATE tblCentral, tblSalesAreas SET tblCentral.OwnerID =
tblSalesAreas!CompanyID
WHERE (((tblCentral.SoldToZip)>=[tblSalesAreas]![StartZip] And
(tblCentral.SoldToZip)
<=[tblSalesAreas]![EndZip]));

UPDATE tblCentral
SET tblCentral.OwnerID =
Dlookup("companyID","tblSalesAreas",
"SoldToZip between [StartZip] And [EndZip]");
--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **

Jun 27 '08 #6
"KC-Mass" <connearneyATcomcastDOTnetwrote in
news:fO******************************@comcast.com:
Thanks very much.

"Bob Quintal" <rq******@sPAmpatico.cawrote in message
news:Xn**********************@66.175.223.2...
>"KC-Mass" <connearneyATcomcastDOTnetwrote in
news:EN******************************@comcast.com :
>>I have two tables related to sales transactions and assigned
areas.

The tblSalesArea has SalesAreaID an autonumber
StartZip, Text
EndZip, Text

The tblSales has many fields detailing all the sales. The two
fields of concern are
ZipCode, Text and SalesAreaID a number.

I need to populate the tblSales!SalesAreaID with the
tbleSalesArea!SalesAreaID
based on the zipcode being between tblSalesArea!startzip and
tblSalesArea!endzip.

This is where I am and it doesn't work. I suspect because the
tables are not joined.
I could open two datasets and do it pretty easily in code but
that would be slow.
Any Ideas??

Thx

UPDATE tblCentral, tblSalesAreas SET tblCentral.OwnerID =
tblSalesAreas!CompanyID
WHERE (((tblCentral.SoldToZip)>=[tblSalesAreas]![StartZip] And
(tblCentral.SoldToZip)
<=[tblSalesAreas]![EndZip]));

UPDATE tblCentral
SET tblCentral.OwnerID =
Dlookup("companyID","tblSalesAreas",
"SoldToZip between [StartZip] And [EndZip]");
--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **


You may need to change the last line to
"SoldToZip between " & [StartZip] & " And " & [EndZip] );
or even
"SoldToZip between """ & [StartZip] & """ And """ & [EndZip] &
"""");

--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **
Jun 27 '08 #7
rkc
Bob Quintal wrote:
"KC-Mass" <connearneyATcomcastDOTnetwrote in
news:fO******************************@comcast.com:
>Thanks very much.

"Bob Quintal" <rq******@sPAmpatico.cawrote in message
news:Xn**********************@66.175.223.2...
>>"KC-Mass" <connearneyATcomcastDOTnetwrote in
news:EN******************************@comcast.co m:

I have two tables related to sales transactions and assigned
areas.

The tblSalesArea has SalesAreaID an autonumber
StartZip, Text
EndZip, Text

The tblSales has many fields detailing all the sales. The two
fields of concern are
ZipCode, Text and SalesAreaID a number.

I need to populate the tblSales!SalesAreaID with the
tbleSalesArea!SalesAreaID
based on the zipcode being between tblSalesArea!startzip and
tblSalesArea!endzip.

This is where I am and it doesn't work. I suspect because the
tables are not joined.
I could open two datasets and do it pretty easily in code but
that would be slow.
Any Ideas??

Thx

UPDATE tblCentral, tblSalesAreas SET tblCentral.OwnerID =
tblSalesAreas!CompanyID
WHERE (((tblCentral.SoldToZip)>=[tblSalesAreas]![StartZip] And
(tblCentral.SoldToZip)
<=[tblSalesAreas]![EndZip]));

UPDATE tblCentral
SET tblCentral.OwnerID =
Dlookup("companyID","tblSalesAreas",
"SoldToZip between [StartZip] And [EndZip]");
--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **

You may need to change the last line to
"SoldToZip between " & [StartZip] & " And " & [EndZip] );
or even
"SoldToZip between """ & [StartZip] & """ And """ & [EndZip] &
"""");
UPDATE tblCentral, tblSalesAreas
SET tblCentral.OwnerID = tblSalesAreasCompanyID
WHERE tblCentral.SoldToZip
BETWEEN tblSalesAreas.StartZip
And tblSalesAreas.EndZip
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dan Berlin | last post by:
I have two tables: T1 : Key as bigint, Data as char(20) - size: 61M records T2 : Key as bigint, Data as char(20) - size: 5M records T2 is the smaller, with 5 million records. They both have...
2
by: sqlgoogle | last post by:
Hi I'm having update problem. Here is the senario I have to different db server (SQL Server) linked with each other In DB Server 1 I have 2 tables & In DB Server 2 I have 3 tables. I have...
2
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing to wrong records and I need to fix them using an...
1
by: septen | last post by:
Hi, I have a select query of 12 tables. The SQL code is as follows: SELECT OptChannelRangeAve.ChannelRangeMin, OptChannelRangeAve.ChannelRangeMax, OptChannelRangeAve.SampleAveraging,...
2
by: NigelMThomas | last post by:
I have an especially challenging problem. I know there are a few geniuses in this group so perhaps; you can advise me whether or not this can be done as an update query in Access. Thanks. I am...
2
by: Fendi Baba | last post by:
I created a person table with various fields such as Suffix, Salutation, etc, Some of these fields may not be mandatory for example suffix. In the actual table itself, I only have a field for...
1
by: racquetballer | last post by:
I need to to an update query that involves three tables: table Dealer needs to be updated with data from table Personnel and table Title. Dealer is joined to Personnel where Dealer.Dealer_Code =...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
5
by: Ferasse | last post by:
Hi, I'm an occasional Ms-Access developer, so there is still a lot of stuff that I don't get... Right now, I'm working on a database that stores contractual information. One of the form that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.