A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Convert datatype using query



 
 
Thread Tools Display Modes
  #1  
Old November 20th, 2009, 05:57 PM posted to microsoft.public.access.queries
ReneeD
external usenet poster
 
Posts: 14
Default Convert datatype using query

I have create a query which combines two tables; ASSETS and UNITINFO. The
UNITINFO table is linked from another database and the ASSETS table has a
field that looks up a field called UNIT # from the UNITINFO table. Both
fields are called UNIT # but the datatype on the UNITINFO table is set to
Text and the UNIT # field on the ASSETS table is set to Number since it is a
lookup field. I cannot change the datatype on the UNITINFO table to Number
as the field contains both numbers and text. So when I ran my query that I
created to pull data from both tables it gave me an error because the two
fields datatypes don't match.

I am thinking I need to use a query to change the datatype on the UNIT #
field in the ASSETS table to Text in order to get this query to work.

Can anyone show me how to go about this if its possible?

Thank you
  #2  
Old November 20th, 2009, 06:18 PM posted to microsoft.public.access.queries
Ken Snell
external usenet poster
 
Posts: 177
Default Convert datatype using query

Use a non-equijoin to join the two tables. This type of join allows you to
use expressions/functions in the join's ON clause. Note that this type of
query will not be updatable.

You'll need to build this type of query in the SQL view (cannot do it in
datagrid/design view).

SELECT ASSETS.*, UNITINFO.*
FROM ASSETS INNER JOIN UNITINFO
ON CStr(ASSETS.[UNIT #]) = UNITINFO.[UNIT #];

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"ReneeD" wrote in message
...
I have create a query which combines two tables; ASSETS and UNITINFO. The
UNITINFO table is linked from another database and the ASSETS table has a
field that looks up a field called UNIT # from the UNITINFO table. Both
fields are called UNIT # but the datatype on the UNITINFO table is set to
Text and the UNIT # field on the ASSETS table is set to Number since it is
a
lookup field. I cannot change the datatype on the UNITINFO table to
Number
as the field contains both numbers and text. So when I ran my query that
I
created to pull data from both tables it gave me an error because the two
fields datatypes don't match.

I am thinking I need to use a query to change the datatype on the UNIT #
field in the ASSETS table to Text in order to get this query to work.

Can anyone show me how to go about this if its possible?

Thank you



  #3  
Old November 20th, 2009, 06:58 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Convert datatype using query

Try this --
qryASSETS --
SELECT [ASSETS].*
FROM [ASSETS];

SELECT [qryASSETS].*, [UNITINFO].*
FROM qryASSETS LEFT JOIN UNITINFO ON [qryASSETS].[UNIT #] = [UNITINFO].[UNIT
#];


--
Build a little, test a little.


"ReneeD" wrote:

I have create a query which combines two tables; ASSETS and UNITINFO. The
UNITINFO table is linked from another database and the ASSETS table has a
field that looks up a field called UNIT # from the UNITINFO table. Both
fields are called UNIT # but the datatype on the UNITINFO table is set to
Text and the UNIT # field on the ASSETS table is set to Number since it is a
lookup field. I cannot change the datatype on the UNITINFO table to Number
as the field contains both numbers and text. So when I ran my query that I
created to pull data from both tables it gave me an error because the two
fields datatypes don't match.

I am thinking I need to use a query to change the datatype on the UNIT #
field in the ASSETS table to Text in order to get this query to work.

Can anyone show me how to go about this if its possible?

Thank you

  #4  
Old November 23rd, 2009, 03:51 PM posted to microsoft.public.access.queries
ReneeD
external usenet poster
 
Posts: 14
Default Convert datatype using query

I have done this assuming I had to create two queries; one called qryASSETS
and one having selected this new query and my UNITINFO table and putting in
the code in the sql view. Should I be able to run the second query? Because
I tried to and it gives me the message 'type mismatch in expression'.

Renee

"KARL DEWEY" wrote:

Try this --
qryASSETS --
SELECT [ASSETS].*
FROM [ASSETS];

SELECT [qryASSETS].*, [UNITINFO].*
FROM qryASSETS LEFT JOIN UNITINFO ON [qryASSETS].[UNIT #] = [UNITINFO].[UNIT
#];


--
Build a little, test a little.


"ReneeD" wrote:

I have create a query which combines two tables; ASSETS and UNITINFO. The
UNITINFO table is linked from another database and the ASSETS table has a
field that looks up a field called UNIT # from the UNITINFO table. Both
fields are called UNIT # but the datatype on the UNITINFO table is set to
Text and the UNIT # field on the ASSETS table is set to Number since it is a
lookup field. I cannot change the datatype on the UNITINFO table to Number
as the field contains both numbers and text. So when I ran my query that I
created to pull data from both tables it gave me an error because the two
fields datatypes don't match.

I am thinking I need to use a query to change the datatype on the UNIT #
field in the ASSETS table to Text in order to get this query to work.

Can anyone show me how to go about this if its possible?

Thank you

  #5  
Old November 24th, 2009, 05:23 PM posted to microsoft.public.access.queries
ReneeD
external usenet poster
 
Posts: 14
Default Convert datatype using query

I have tried the query you told me to create and it runs the query but it
only shows 17 records and it should a lot more than that. Why wouldn't the
other entries show up when I know that the unit #'s match in both tables?

Renee

"Ken Snell" wrote:

Use a non-equijoin to join the two tables. This type of join allows you to
use expressions/functions in the join's ON clause. Note that this type of
query will not be updatable.

You'll need to build this type of query in the SQL view (cannot do it in
datagrid/design view).

SELECT ASSETS.*, UNITINFO.*
FROM ASSETS INNER JOIN UNITINFO
ON CStr(ASSETS.[UNIT #]) = UNITINFO.[UNIT #];

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"ReneeD" wrote in message
...
I have create a query which combines two tables; ASSETS and UNITINFO. The
UNITINFO table is linked from another database and the ASSETS table has a
field that looks up a field called UNIT # from the UNITINFO table. Both
fields are called UNIT # but the datatype on the UNITINFO table is set to
Text and the UNIT # field on the ASSETS table is set to Number since it is
a
lookup field. I cannot change the datatype on the UNITINFO table to
Number
as the field contains both numbers and text. So when I ran my query that
I
created to pull data from both tables it gave me an error because the two
fields datatypes don't match.

I am thinking I need to use a query to change the datatype on the UNIT #
field in the ASSETS table to Text in order to get this query to work.

Can anyone show me how to go about this if its possible?

Thank you



.

  #6  
Old November 24th, 2009, 05:59 PM posted to microsoft.public.access.queries
Ken Snell
external usenet poster
 
Posts: 177
Default Convert datatype using query

If those records don't show up, they likely don't have the value in UNIT #
that you think they do. Look at the values for the "missing" records, and be
sure that there are no leading spaces, no trailing spaces, and no trailing
carriage return or line feed character.

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"ReneeD" wrote in message
...
I have tried the query you told me to create and it runs the query but it
only shows 17 records and it should a lot more than that. Why wouldn't the
other entries show up when I know that the unit #'s match in both tables?

Renee

"Ken Snell" wrote:

Use a non-equijoin to join the two tables. This type of join allows you
to
use expressions/functions in the join's ON clause. Note that this type of
query will not be updatable.

You'll need to build this type of query in the SQL view (cannot do it in
datagrid/design view).

SELECT ASSETS.*, UNITINFO.*
FROM ASSETS INNER JOIN UNITINFO
ON CStr(ASSETS.[UNIT #]) = UNITINFO.[UNIT #];

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"ReneeD" wrote in message
...
I have create a query which combines two tables; ASSETS and UNITINFO.
The
UNITINFO table is linked from another database and the ASSETS table has
a
field that looks up a field called UNIT # from the UNITINFO table.
Both
fields are called UNIT # but the datatype on the UNITINFO table is set
to
Text and the UNIT # field on the ASSETS table is set to Number since it
is
a
lookup field. I cannot change the datatype on the UNITINFO table to
Number
as the field contains both numbers and text. So when I ran my query
that
I
created to pull data from both tables it gave me an error because the
two
fields datatypes don't match.

I am thinking I need to use a query to change the datatype on the UNIT
#
field in the ASSETS table to Text in order to get this query to work.

Can anyone show me how to go about this if its possible?

Thank you



.



  #7  
Old November 24th, 2009, 07:23 PM posted to microsoft.public.access.queries
ReneeD
external usenet poster
 
Posts: 14
Default Convert datatype using query

All the unit # entries should match from the UNITINFO table to the ASSETS
table since the unit # field on the ASSETS table is a lookup field to the
unit # field on the UNITINFO table. That is why I don't understand why it
would only select certain records.

"Ken Snell" wrote:

If those records don't show up, they likely don't have the value in UNIT #
that you think they do. Look at the values for the "missing" records, and be
sure that there are no leading spaces, no trailing spaces, and no trailing
carriage return or line feed character.

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"ReneeD" wrote in message
...
I have tried the query you told me to create and it runs the query but it
only shows 17 records and it should a lot more than that. Why wouldn't the
other entries show up when I know that the unit #'s match in both tables?

Renee

"Ken Snell" wrote:

Use a non-equijoin to join the two tables. This type of join allows you
to
use expressions/functions in the join's ON clause. Note that this type of
query will not be updatable.

You'll need to build this type of query in the SQL view (cannot do it in
datagrid/design view).

SELECT ASSETS.*, UNITINFO.*
FROM ASSETS INNER JOIN UNITINFO
ON CStr(ASSETS.[UNIT #]) = UNITINFO.[UNIT #];

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"ReneeD" wrote in message
...
I have create a query which combines two tables; ASSETS and UNITINFO.
The
UNITINFO table is linked from another database and the ASSETS table has
a
field that looks up a field called UNIT # from the UNITINFO table.
Both
fields are called UNIT # but the datatype on the UNITINFO table is set
to
Text and the UNIT # field on the ASSETS table is set to Number since it
is
a
lookup field. I cannot change the datatype on the UNITINFO table to
Number
as the field contains both numbers and text. So when I ran my query
that
I
created to pull data from both tables it gave me an error because the
two
fields datatypes don't match.

I am thinking I need to use a query to change the datatype on the UNIT
#
field in the ASSETS table to Text in order to get this query to work.

Can anyone show me how to go about this if its possible?

Thank you


.



.

  #8  
Old November 24th, 2009, 10:36 PM posted to microsoft.public.access.queries
Ken Snell
external usenet poster
 
Posts: 177
Default Convert datatype using query

Show us examples of the values that are not matching.

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"ReneeD" wrote in message
...
All the unit # entries should match from the UNITINFO table to the ASSETS
table since the unit # field on the ASSETS table is a lookup field to the
unit # field on the UNITINFO table. That is why I don't understand why it
would only select certain records.

"Ken Snell" wrote:

If those records don't show up, they likely don't have the value in UNIT
#
that you think they do. Look at the values for the "missing" records, and
be
sure that there are no leading spaces, no trailing spaces, and no
trailing
carriage return or line feed character.

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"ReneeD" wrote in message
...
I have tried the query you told me to create and it runs the query but
it
only shows 17 records and it should a lot more than that. Why wouldn't
the
other entries show up when I know that the unit #'s match in both
tables?

Renee

"Ken Snell" wrote:

Use a non-equijoin to join the two tables. This type of join allows
you
to
use expressions/functions in the join's ON clause. Note that this type
of
query will not be updatable.

You'll need to build this type of query in the SQL view (cannot do it
in
datagrid/design view).

SELECT ASSETS.*, UNITINFO.*
FROM ASSETS INNER JOIN UNITINFO
ON CStr(ASSETS.[UNIT #]) = UNITINFO.[UNIT #];

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"ReneeD" wrote in message
...
I have create a query which combines two tables; ASSETS and UNITINFO.
The
UNITINFO table is linked from another database and the ASSETS table
has
a
field that looks up a field called UNIT # from the UNITINFO table.
Both
fields are called UNIT # but the datatype on the UNITINFO table is
set
to
Text and the UNIT # field on the ASSETS table is set to Number since
it
is
a
lookup field. I cannot change the datatype on the UNITINFO table to
Number
as the field contains both numbers and text. So when I ran my query
that
I
created to pull data from both tables it gave me an error because
the
two
fields datatypes don't match.

I am thinking I need to use a query to change the datatype on the
UNIT
#
field in the ASSETS table to Text in order to get this query to
work.

Can anyone show me how to go about this if its possible?

Thank you


.



.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:30 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.