convert data type

Dartagnan

Active Member
Joined
Jun 19, 2002
Messages
386
I am getting a "type mismatch in expression" when I try to run a query. I get the error because one table has the Data Type, for loan number, as number and the other table has the Data Type, for loan number, as text.

Is there a way I can convert the data type while I am building my query?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I would try to add a calculated field in the query.

Loan Number (data type: text)
In the calculated field I would just add this field, but in the properties I would change it to number. And then base your query off this one and not the other.

I don't know if this would work but this is what I would try.
 
Upvote 0
The easiest way is to add an intermediate query. So say the table with Loan Number formatted as text is called tblLoanText. Make a query (say qryLoanText) that brings in all fields EXCEPT for Loan Number. For Loan Number (say it is called LoanNum), use a blank column and do something like this:

LoanNum2: Val(LoanNum)

Then join your numeric loan number table to the query you just created.

HTH,

Russell
 
Upvote 0
Convert Data Type

This is a little out of my league. Is there a command like CSTR or CLNG that would do the trick?
 
Upvote 0
It really is not out of your league. If you can create a query where you join 2 tables, then you can do this.

For the query I was talking about, just select all the fields in the table that you want to use (all of them, if you want them all, but don't choose *). Then just change the Loan Number field (again, for example purposes I'll say it is named LoanNum).

So maybe your query looks like this before changes:


mrxl030424a.gif
</p>
The only change you'd need to make would be to the LoanNum field, something like this:


mrxl030424b.gif
</p>
Save the query, and instead of joining the table to the other table, join the table to the query you just saved (which will have LoanNum - renamed as Loan2 - as numeric).

HTH,

Russell
 
Upvote 0

Forum statistics

Threads
1,221,525
Messages
6,160,327
Members
451,637
Latest member
hvp2262

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top