Question

Alright, I realize that what I am about to ask may not be possible, which I can live with. But If it is possible it will make my life a lot easier.

Within my MS Access Database, I am attempting to query 2 tables. These tables are both linked to my Access DB, one is linked to an Excel file (MSSB Reps DTP) containing a dump from a seperate DB2 database. The other table in my query (SalesPage DNK Rep Query) is linked to another Access DB, which is in turn linked to a SQL databse. Here is an image of the Query design screen:

My Accdb Query Design Screen

Where the tables are linked is not so much important as the fact that since they are linked tables, and since this is MS Access, I can not edit the tables. Therefore, I can not simply pop into design mode of either table and change the data type of a given column.

Each table has a column named CRD Number. I want to create an inner join between these two tables based on this column. Just a simple, everyday, inner join. I can not however, because the CRD Number column is stored as a Number for the MSSB Reps DTP table, and as text in the SalesPage DNK Rep Query table.

I was wondering if there is some way to temporarily use a fucntion to "cast" the CRD Number column fromo the MSSB Reps DTP table as text, so that I can run this query. However, any solution will be appreciated. Just don't tell me to edit the Excel document. I am trying very hard to avoid that for various reasons.

Was it helpful?

Solution

You can use CStr to cast the number as text.

SELECT *
FROM
    [MSSB Reps DTP] AS m
    INNER JOIN [SalesPage DNK Rep Query] AS s
    ON CStr(m.[CRD Number]) = s.[CRD Number];

The Access query designer may refuse to display that join in Design View, but you can switch to SQL View and edit the statement text.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top