Share via

Data Type Mismatch

Anonymous
2024-09-17T15:22:36+00:00

I used the expression below to pull an area code from a tabled phone number:

AreaCode: (Mid([dbo_accounts!HomePhone],(Len([dbo_accounts!HomePhone])-8)-1,3))

The above works, however, then I attempt a join the field with a US area code table, it tells me there's a data type mismatch. I tried formatting the above expression to output a number to match the US area code table, but it still doesn't like the join.

How can I get around this?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2024-09-18T17:25:09+00:00

I took this issue a different direction. Since I can control 1 of 2 joined tables in the query, I changed the local table (field) to a short-text data type. Issue resolved.

Was this answer helpful?

0 comments No comments

8 additional answers

Sort by: Most helpful
  1. Anonymous
    2024-09-17T21:27:59+00:00

    Hi,

    It's a short text field in the DB.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-09-17T21:21:14+00:00

    AreaCode: (Mid([dbo_accounts!HomePhone],(Len([dbo_accounts!HomePhone])-8)-1,3))

    The above works, however, then I attempt a join the field with a US area code table, it tells me there's a data type mismatch.

    Hi shubox56,

    What is the type of the area code in the code table: Text, Integer, Long, ...

    You could use the functions CInt or CLng to convert Text to Integer or Long.

    "Numbers" like the area code, telephone-numbers, zip-codes, assurance-numbers, etc., that are not used for any calculation but only for identifying, I always define them as Text/String.

    In that case I would download the table, and convert the area code to Text.

    Imb.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-09-17T16:18:17+00:00

    Hi Ken,

    I tried Val earlier without luck. Data type mismatch.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2024-09-17T16:06:33+00:00

    Try:

    AreaCode: Val(Mid([dbo_accounts!HomePhone],(Len([dbo_accounts!HomePhone])-8)-1,3))

    Was this answer helpful?

    0 comments No comments