Make table query error (1 Viewer)

standenman

Member
Local time
Today, 02:14
Joined
May 12, 2016
Messages
45
I am trying to make a table with this code:
Code:
SELECT NPIMonsterPared.NPI, NPIMonsterPared.[Entity Type Code], NPIMonsterPared.[Provider First Name], NPIMonsterPared.[Provider Middle Name], NPIMonsterPared.[Provider Last Name (Legal Name)], NPIMonsterPared.[Provider First Line Business Practice Location Address], NPIMonsterPared.[Provider Second Line Business Practice Location Address], NPIMonsterPared.[Provider Business Practice Location Address State Name], NPIMonsterPared.[Provider Business Mailing Address Postal Code], NPIMonsterPared.[Provider Business Mailing Address Postal Code], NPIMonsterPared.[Provider Business Mailing Address Telephone Number], NPIMonsterPared.[Provider Business Mailing Address Fax Number], NPIMonsterPared.[Provider Business Practice Location Address State Name] INTO DallasTXOrgaNPIs
FROM NPIMonsterPared
WHERE (((NPIMonsterPared.[Entity Type Code])=2) AND ((NPIMonsterPared.[Provider Business Practice Location Address City Name])="dallas") AND ((NPIMonsterPared.[Provider Business Practice Location Address State Name])="TX"));

When I try to run the query I get this non-sensical response from Access:
 

Attachments

  • Screenshot (18).png
    Screenshot (18).png
    1.7 MB · Views: 39

June7

AWF VIP
Local time
Today, 01:14
Joined
Mar 9, 2014
Messages
5,472
I can't see anything wrong with SQL. Why create table with simply filtered recordset?

Are you pulling every field from NPIMonsterPared?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:14
Joined
Feb 19, 2013
Messages
16,612
very poor naming practice which may be contributing to the problem. Try removing all the spaces and non alphanumeric characters
 

standenman

Member
Local time
Today, 02:14
Joined
May 12, 2016
Messages
45
The names come from the excel spreadseet that I downloaded. Access is such a fussy little...
 

standenman

Member
Local time
Today, 02:14
Joined
May 12, 2016
Messages
45
When I try to rename this field to "ProviderBusinessMailingState" MS access says that it does not follow Access object-naming rules.
 

June7

AWF VIP
Local time
Today, 01:14
Joined
Mar 9, 2014
Messages
5,472
This is a linked worksheet? Does it open in datasheet view?

Built SQL with designer and tried to run there?
 

plog

Banishment Pending
Local time
Today, 04:14
Joined
May 11, 2011
Messages
11,646
SELECT NPIMonsterPared.NPI, NPIMonsterPared.[Entity Type Code]
, NPIMonsterPared.[Provider First Name]
, NPIMonsterPared.[Provider Middle Name]
, NPIMonsterPared.[Provider Last Name (Legal Name)]
, NPIMonsterPared.[Provider First Line Business Practice Location Address]
, NPIMonsterPared.[Provider Second Line Business Practice Location Address]
, NPIMonsterPared.[Provider Business Practice Location Address State Name]
, NPIMonsterPared.[Provider Business Mailing Address Postal Code]
, NPIMonsterPared.[Provider Business Mailing Address Postal Code]

, NPIMonsterPared.[Provider Business Mailing Address Telephone Number]
, NPIMonsterPared.[Provider Business Mailing Address Fax Number]
, NPIMonsterPared.[Provider Business Practice Location Address State Name]

Not 100% sure, but perhaps your duplicated fields in the SELECT are causing this. Clean those up and try again.
 

June7

AWF VIP
Local time
Today, 01:14
Joined
Mar 9, 2014
Messages
5,472
Dang! Good eye, plog.

If this had been built with designer, I would have expected alias names for those dupes.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:14
Joined
Feb 28, 2001
Messages
27,186
The error message says you have named something NPIMonsterPared_Provider Business Practice Location Address State Name when it is clear that the underscore SHOULD be a dot. So this error is telling you that you have a typo involving that field. Underscores are permitting in field names so that typo just looks like a big, long, ugly field name. If that is actually what happened, then another problem is that you have 70 bytes in a field name, and I think the limit is shorter than that. If true, then the non-sensical response derives from a non-sensical field name.

Access WILL handle this correctly if you get the punctuation right, but these fields are suspicious. It ALMOST seems as though you are somehow combining what should be individual short fields names into one long field name. I almost don't want to know what it really represents, but I have to say that your naming convention probably could use some revisitation.
 

June7

AWF VIP
Local time
Today, 01:14
Joined
Mar 9, 2014
Messages
5,472
Doc, the SQL doesn't show an underscore anywhere. Access won't allow a field name to exceed 64 characters in table design. However, it does allow in query in Design View. Creating alias field name over 64 characters in SQL View fails. SQL View will show field name over 64 characters when created in Design View but editing it will trigger error if it is still over 64 when leaving SQL View.
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 10:14
Joined
Feb 19, 2013
Messages
16,612
The names come from the excel spreadseet that I downloaded. Access is such a fussy little...
downloaded means what exactly? you linked to the excel spreadsheet or you imported it? in either case using transferspreadsheet or sql?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:14
Joined
Feb 28, 2001
Messages
27,186
Doc, the SQL doesn't show an underscore anywhere.

But the error message DOES. Was the query shown to us derived from a copy-paste or a re-enter by hand?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:14
Joined
Feb 19, 2002
Messages
43,275
Access is such a fussy little...
It is actually not fussy enough. In a "good" language, there should be only one way to do anything. VBA is actually too loosey-goosey. Excel is not a relational database so it caters to people who know nothing about anything.

The first thing you should do is to get rid of these ridiculously long names. Do it either by importing the data into a table with rational names or by using a query to alias the long names.
 

Users who are viewing this thread

Top Bottom