Несоответствие типов в выражении join ошибка 3615

I’ve got two tables.
The first one looks like this. The type of the numbers is decimal.

TABLE1
T1NUMBER  T1INFORMATION
123456    Stuff1
123457    Stuff2
123458    Stuff3

My other table looks similar. Basically the id is the same as in the other table, but with two extra characters at the end.

TABLE2
T2NUMBER    T2INFORMATION
123456L1    Important Info1
123457L1    Important Info2
123458L1    Important Info3

To join the tables, I made a query to cut the extra characters. I know, that I can only match decimal colums with decimal ones. So I added a function, that converts the string I got to a decimal. The result of the query looks like this.

QUERY1
Q1NUMBER  Q1INFORMATION
123456    Important Info1
123457    Important Info2
123458    Important Info3

The function I used to get a decimal value is this one. I added it as a module.

Function NewCDec(MyVal)
   NewCDec = CDec(MyVal)
End Function

Let’s finally get to my problem. I want to join TABLE1 with QUERY1 on the numerical columns. Both should now be decimal values and should be joinable. But I always get error 3615 (Type mismatch in JOIN expression). Why do I still get that error? Can anyone help me fix it?

My query should look like this in the end:

RESULT
NUMBER    T1INFORMATION  Q1INFORMATION
123456    Stuff1         Important Info1
123457    Stuff2         Important Info2
123458    Stuff3         Important Info3

Lucien


  • #1

I am getting the following error when trying to execute a query:

Type mismatch in JOIN expression. (Error 3615)
A JOIN expression is attempting to join two tables on fields of incompatible
data types. For example, you will get this error if you attempt to join a
Memo field with a Text field.

I imported a table from an Excel spreadsheet that I have linked to an
existing table. I think this is where the problem is, but how do I fix it?

thanks,
Chris

Advertisements

Arvin Meyer [MVP]


  • #2

To resolve the problem, first identify the join that’s causing the problem.
I do that by makeing several copies to the query and eliminating the joins
until I find the one that causes the error. Then either change the datatype
in the table or build a query which converts the datatype of a column

Example: CStr([MyField])

Build a second query which joins on the results of the first.

Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Wayne Morgan


  • #3

Open the imported table in design mode. Go to the field you are trying to
make the join on and see what the Data Type for that field is. Open the
other table in design mode and see what the Data Type is for the field that
is the other side of the join. They both need to be the same. Adjust the
imported table as needed.

Lucien


  • #4

Ok, I found the join that is the problem. In my imported table the data type
for the field is Number. I need to adjust it to Text so it will match my
other table. How do I do that?

Wayne Morgan


  • #5

Open the table in design view. Place the cursor in the field that’s the
problem. Change the data type in the 2nd column to Text. In the bottom part
of the window, make sure that Field Size is at least as large (larger is ok)
at the longest data in the field (for a text field this would be the record
with the greatest number of characters). Click Save and close the table.

Advertisements

Lucien


  • #6

This worked great.

Thank you for the time.

Wayne Morgan said:

Open the table in design view. Place the cursor in the field that’s the
problem. Change the data type in the 2nd column to Text. In the bottom part
of the window, make sure that Field Size is at least as large (larger is ok)
at the longest data in the field (for a text field this would be the record
with the greatest number of characters). Click Save and close the table.

Advertisements

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

1265 / 901 / 440

Регистрация: 21.10.2012

Сообщений: 2,566

1

Ошибка «Несоответствие типа в выражении» при запросе

04.10.2015, 20:07. Показов 33766. Ответов 5


Студворк — интернет-сервис помощи студентам

Здравствуйте. Создаю запрос (Запрос1), но при попытке его выполнить выскакивает окошко с текстом «Несоответствие типа в выражении». Что нужно изменить?



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

04.10.2015, 20:07

5

Эксперт MS Access

2833 / 1375 / 215

Регистрация: 13.05.2011

Сообщений: 4,213

04.10.2015, 20:41

2

АлександрКом, Править ни чего не стал, т.к. не знаю как у Вас должно быть, но ошибку нашел: В таблице Возврат поле № заказа по схеме данных связана с полем № заказа из таблицы Заказы, а в свойствах поля стоит подстановка из таблицы Туры новые поле Тур.
Все таки сделаю на вашем примере связь как есть и чтобы работало.



0



Эксперт MS Access

2833 / 1375 / 215

Регистрация: 13.05.2011

Сообщений: 4,213

04.10.2015, 20:46

3

Лучший ответ Сообщение было отмечено АлександрКом как решение

Решение

АлександрКом, Вот ловите. Еще в запросе Запрос1 убрал связь РейсыЗаказы. Они уже связаны через две таблицы с Ткрами.



1



Эксперт MS Access

2833 / 1375 / 215

Регистрация: 13.05.2011

Сообщений: 4,213

04.10.2015, 20:52

4

Еще замечание: делайте ключевые поля с типом данных Счетчик. А так же откажитесь от подстановок в полях таблиц.



0



1265 / 901 / 440

Регистрация: 21.10.2012

Сообщений: 2,566

04.10.2015, 21:07

 [ТС]

5

Спасибо большое! Сам много чего изменил в процессе создания базы и про поля подстановки забыл вообще Ещё раз спасибо!

Добавлено через 2 минуты

Цитата
Сообщение от Вячеслав Я
Посмотреть сообщение

А так же откажитесь от подстановок в полях таблиц

На начальном этапе мне казалось так проще, но сейчас понимаю, что поля подстановки нужно использовать только на формах, иначе не избежать ошибок



1



Эксперт MS Access

2833 / 1375 / 215

Регистрация: 13.05.2011

Сообщений: 4,213

04.10.2015, 21:08

6

Цитата
Сообщение от АлександрКом
Посмотреть сообщение

поля подстановки нужно использовать только на формах, иначе не избежать ошибок

Совершенно справедливо!



1



Получено сообщение о несоответствии типов данных

Access для Microsoft 365 Access 2021 Access 2019 Access 2016 Access 2013 Access 2010 Access 2007 Еще…Меньше

Эта ошибка указывает на то, что Access не может связать входное значение с ожидаемым для него типом данных. Например, если передать приложению Access текстовую строку вместо числа, возникнет ошибка несоответствия типов данных.

Для исправления этой проблемы можно сделать следующее:

  • Если вы изменили значение по умолчанию для поля в таблице и у вас появляется сообщение о несоответствии типов данных при попытке добавить новые записи, откройте таблицу в режиме конструктора и убедитесь в том, что выражение, заданное в качестве значения по умолчанию для поля, возвращает данные того же типа, что и у поля. Например, если тип поля — Число, не заключайте выражение для значения по умолчанию в кавычки (например, «1» возвращает текстовую строку, а не число).

  • Убедитесь условия что столбец тип данных совпадает с его тип данных поля. Если задать текстовые условия для числового поля или поля даты и времени, вы получите эту ошибку.

    Например, если ввести условия «50» или «13.12.2012»,возвращается сообщение об ошибке, так как Access интерпретирует значения в кавычках как текст, а не числа. Поэтому не забудьте удалить эти кавычка. Вы будете знать, что введите допустимую дату в поле «Условия», так как рядом с датой будут отображаться знаки #, например #12.13.12#.

Конфликт типов данных также может возникать в следующих ситуациях:

  • Вы задаете условие для поле подстановки, и условие использует значения, показанные в списке подстановок (например, имя), вместо связанных с ними значений внешний ключ (например, ИД). Так как значения внешнего ключа фактически являются значениями, сохраненными в базовой таблице, их следует использовать при вводе условия для поля.

  • Вы ввели знак доллара ($) в условии, заданном в поле валюты. Удалите знак доллара и просмотрите результаты.

    Если заданное числовое условие не является числом, оно окружено кавычками. При вводе знака $ приложение Access автоматически заключает строку в кавычки.

  • Убедитесь, что тип данных каждой пары связанных полей в запросе одинаков. Если это не так, измените тип данных одного из связанных полей, чтобы он соответствовал типу данных другого поля, иначе возникнет ошибка несоответствия.

Нужна дополнительная помощь?

Нужны дополнительные параметры?

Изучите преимущества подписки, просмотрите учебные курсы, узнайте, как защитить свое устройство и т. д.

В сообществах можно задавать вопросы и отвечать на них, отправлять отзывы и консультироваться с экспертами разных профилей.

  • #1

I was trying to bring down values from two different tables that have County(Numeric field) as a common field. But i am getting this error,
Run time error «3615», type mismatch in expression. I donno wat is the reason. Here is the snipet of my query,

SELECT dbo_hpr.ADDRESS, dbo_hpr.PROPNAME, Dbo_Bridges1.CITY, Dbo_Bridges1.ADDRESS
FROM Dbo_Bridges1 INNER JOIN dbo_hpr ON Dbo_Bridges1.[COUNTYCD] = dbo_hpr.[COUNTYCD]
WHERE (((dbo_hpr.ADDRESS) Like Nz(Forms!Prop_Bridges!comboaddr,»~») & «*»))

P.S: Here dbo_hpr — table1
Dbo_Bridges1 — table2
COUNTYCD is the Column name that exists in both the table. Can someone pls help me fixing it. Thanks in advance

  • #2

County(Numeric field) as a common field.. so where is that in your query?

  • #3

COUNTYCD is the field that contains the numeric values of all counties. And I have used in the below query.

SELECT dbo_hpr.ADDRESS, dbo_hpr.PROPNAME, Dbo_Bridges1.CITY, Dbo_Bridges1.ADDRESS
FROM Dbo_Bridges1 INNER JOIN dbo_hpr ON Dbo_Bridges1.[COUNTYCD] = dbo_hpr.[COUNTYCD]
WHERE (((dbo_hpr.ADDRESS) Like Nz(Forms!Prop_Bridges!comboaddr,»~») & «*»)) OR (((dbo_hpr.COUNTYCD)=Forms!Prop_Bridges!combocounty)) & (((Dbo_Bridges1.COUNTYCD)=[Forms]![Prop_Bridges]![Combocounty]));

  • #4

OK — next time you type a question take care to get the variable names right (see your first line).

So check in your two tables if CountyCD is a number in both, and if so, what is the actual content — see if some are null/empty etc

  • #5

The field COUNTYCD in both the tables contains numeric value and yes there are some null values.

  • #6

How do you know it’s CountyCd that gives you grief? Did you check what’s in your combos?

And changing your SQL while I am trying to debug it per remote vision is not going to help either — what the heck is (((dbo_hpr.COUNTYCD)=Forms!Prop_Bridges!combocount y)) & (((Dbo_Bridges1.COUNTYCD)=[Forms]![Prop_Bridges]![Combocounty])) ? It’s neither here nor there — Access will make a Boolean out of the first part, a string out of the second, concatente the two, and it just makes no sense whatsoever,

  • #7

My combo’s are having numeric value in it. I have used a small look up table like below one
CountyName|CountyCD
Oklahoma 12
Payne 13

I didnt know that these values will be concatenated. I assumed that it will check both the conditions. Else how about using this (((dbo_hpr.COUNTYCD)=Forms!Prop_Bridges!combocount y)) OR (((Dbo_Bridges1.COUNTYCD)=[Forms]![Prop_Bridges]![Combocounty]))

  • #8

Else is that possible for you to connect remotely and work on it? I even can’t share the file bcos of its huge size(around 160 mb)

  • #9

The bound field of the combo box is Text, the second column is the numeric field. So you should be referring to the second COLUMN of your combo box.

  • #10

In my query form, what is the Record Source I have to give?? Since it is taking values from two tables, should I have include both the table names in the record source???

  • #11

I will explain in a bit. But what is the first column in the Row Source of your combo box? And also, what is the Bound Column property set to?

Возможно, вам также будет интересно:

  • Несоответствие датчика коленвала и распредвала ошибка
  • Несогласованный деепричастный оборот какая ошибка
  • Несогласованные предложения это какая ошибка
  • Несогласованность слов это какая ошибка
  • Несогласованность слов в предложении какая ошибка

  • Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии