Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA SQL SERVER query

Status
Not open for further replies.

BananaQuaaludes

Programmer
Jun 17, 2003
6
US
Hello,

I have the following query in an Excel vba macro:

SELECT [DELTEK_ORG_ACCT].[ACCT_ID] , [DELTEK_ACCT].[ACCT_NAME] FROM DELTEK_ORG_ACCT INNER JOIN DELTEK_ACCT ON [DELTEK_ORG_ACCT].[ACCT_ID]=[DELTEK_ACCT].[ACCT_ID] WHERE ((([DELTEK_ORG_ACCT].[ORG_ID])='1.1201.01'));

and I get the following error:

run time error 3001: arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

I think it doesn't like my inner join, but I'm not sure why.

Any help would be appreciated!!
 
ON [DELTEK_ORG_ACCT].[ACCT_ID]=[DELTEK_ACCT].[ACCT_ID] WHERE ((([DELTEK_ORG_ACCT].[ORG_ID])='1.1201.01'
I agree with you, there's probably something wrong with the inner join. I'm guessing that either ACCT_ID in the two tables are not defined the same way or ORG_ID isn't a varchar (or char) field. Maybe it's nvarchar, in which case you have to say
WHERE ((([DELTEK_ORG_ACCT].[ORG_ID])=N'1.1201.01'
-Karl
 
Hello Karl,

Thanks for the reply. The error I was getting actually had nothing to do with the join. Apparently VBA likes to see a dot notation between the database name and the table name, as well as between table and column names.

It has to be: database.table.column

Once I changed that it worked. I would have pulled the post down, but didn't see a way to do that.

Thanks anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top