473,396 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

The specified field could refer to more than one table error with curious but inadequate fix

I have a query that is being created in code. When the query is
executed I get the error: "The specified field 'Acct' could refer to
more than one table listed in the FROM clause".

As you can see below, the 'Acct' field is fully qualified in the
subselect. What is interesting is if I cut and re-paste the same exact
query in the SQL view of design mode for the query object, it works
fine. It even works fine if all I do is remove the semi-colon at the
end.

Here is the query:
INSERT INTO DelinquencyData ( FirstInCollections, Acct, PrimaryID,
HostDatabaseID, AcctGrp, AcctType, ProdType, LastName, FirstName,
PersonalID, BirthDate, Address, City, State, PostalCode, Country,
Phone1, Phone2, DelqAmnt, DelqDate, DaysDelq, ChargeOffAmnt,
ChargeOffDate, DaysSinceChargeOff, CurrBalance, PayoffAmnt,
PayoffGoodUntil, NextPayoffAmnt, DelqStatus, LastPaymDate,
LastPaymAmnt, PaymTotal, RecoveryFlag, OpenDate, OpenAmnt, ClosedDate,
CreditLimit, PointScore, Branch, Officer, SpecialDesc, Times15DaysDelq,
Times30DaysDelq, Times60DaysDelq, Times90DaysDelq, Times120DaysDelq,
Times150DaysDelq, Times180DaysDelq, CredBurFlag, Dealer, InterestRate,
PerDiem, GLAcct, RegPmtAmnt, OrigNumPmts, NSFCount, LastNSFDate,
LastNSFCheck, LastNSFAmnt, LastPaymNSF, InterestDate, InterestDue,
MaturityDate, OverdraftProtection, ATMFlag, TextFld1, TextFld2,
TextFld3, TextFld4, TextFld7, TextFld8, TextFld9, TextFld10, TextFld12,
TextFld13, TextFld14, DateFld7, DateFld11 )
SELECT Now() AS FirstInCollections, ImportData.Acct,
ImportData.PrimaryID, ImportData.HostDatabaseID, ImportData.AcctGrp,
ImportData.AcctType, ImportData.ProdType, ImportData.LastName,
ImportData.FirstName, ImportData.PersonalID, ImportData.BirthDate,
replace(nz(ImportData.Address),'|',Chr$(13) & Chr$(10)) AS
DelqDataAddress, ImportData.City, ImportData.State,
ImportData.PostalCode, ImportData.Country, ImportData.Phone1,
ImportData.Phone2, ImportData.DelqAmnt, ImportData.DelqDate,
ImportData.DaysDelq, ImportData.ChargeOffAmnt,
ImportData.ChargeOffDate, ImportData.DaysSinceChargeOff,
ImportData.CurrBalance, ImportData.PayoffAmnt,
ImportData.PayoffGoodUntil, ImportData.NextPayoffAmnt,
ImportData.DelqStatus, ImportData.LastPaymDate,
ImportData.LastPaymAmnt, ImportData.PaymTotal, ImportData.RecoveryFlag,
ImportData.OpenDate, ImportData.OpenAmnt, ImportData.ClosedDate,
ImportData.CreditLimit, ImportData.PointScore, ImportData.Branch,
ImportData.Officer, ImportData.SpecialDesc, ImportData.Times15DaysDelq,
ImportData.Times30DaysDelq, ImportData.Times60DaysDelq,
ImportData.Times90DaysDelq, ImportData.Times120DaysDelq,
ImportData.Times150DaysDelq, ImportData.Times180DaysDelq,
ImportData.CredBurFlag, ImportData.Dealer, ImportData.InterestRate,
ImportData.PerDiem, ImportData.GLAcct, ImportData.RegPmtAmnt,
ImportData.OrigNumPmts, ImportData.NSFCount, ImportData.LastNSFDate,
ImportData.LastNSFCheck, ImportData.LastNSFAmnt,
ImportData.LastPaymNSF, ImportData.InterestDate,
ImportData.InterestDue, ImportData.MaturityDate,
ImportData.OverdraftProtection, ImportData.ATMFlag,
ImportData.TextFld1, ImportData.TextFld2, ImportData.TextFld3,
ImportData.TextFld4, ImportData.TextFld7, ImportData.TextFld8,
ImportData.TextFld9, ImportData.TextFld10, ImportData.TextFld12,
ImportData.TextFld13, ImportData.TextFld14, ImportData.DateFld7,
ImportData.DateFld11
FROM ImportData LEFT JOIN DelinquencyData ON ImportData.Acct =
DelinquencyData.Acct
WHERE (((DelinquencyData.Acct) Is Null));

BTW, instead of the outer join, I originally had the where clause say
"where importdata.acct not in (select acct from delinquencydata)". I
got no errors on that query but it performed horribly.

Any ideas? I need to be able to generate this query in code without
having to go back and edit the query manually.

Thanks.
Kathy

Nov 13 '05 #1
4 5074
How are you creating your query in code? Is it something like:

dim strSQL as string

strSQL = "INSERT INTO DelinquencyData ..."
strSQL = strSQL & "DelqDataAddress, ImportData.City, ...."
strSQL = strSQL & "WHERE (((DelinquencyData.Acct) Is Null))"
CurrentDb.Execute(strSQL)

Perhaps one or more of the individual strings you are concatenating
together to create your SQL are too long. I believe VBA has a
limitation of 1023 characters per line...

Also, if this query works in VBA without the semicolon at the end,
leave it off. The SQL view of the query window seems to be the only
thing that needs it. Neither the RunSQL method of the DoCmd object nor
the Execute method of the Database object require it.

HTH,
Bruce

Nov 13 '05 #2
Yes, I am creating the query with multiple concatenations using string
variables. I actually don't put the semi-colon in, Access adds that
(as well as the extra unneeded parentheses in the where clause) when
the query is created via CreateQueryDef.

Kathy

Nov 13 '05 #3

Check the _code_ that generates the SQL, _very_ carefully. Don't look
at what you see in the Design grid, as the Access query Editor will
"adjust" your query for you when you open it.

If possible, cut and paste the SQL string into the debug window and
have it print it out in the debug editor. Look at the results.

I'd bet that in the _code_ you use to write this query, you are not
explicitly setting the acct field to what it needs to be. (The editor
however, is fixing it for you when you open it up the Query editor.)

On 25 Oct 2005 14:01:19 -0700, "Kathy" <ka***@regardingbooks.com>
wrote:
Yes, I am creating the query with multiple concatenations using string
variables. I actually don't put the semi-colon in, Access adds that
(as well as the extra unneeded parentheses in the where clause) when
the query is created via CreateQueryDef.

--
Drive C: Error. (A)bort (R)etry (S)mack The Darned Thing

Nov 13 '05 #4
Wow, that was it !!!
I knew Access was adding all the parens, but I didn't think about the
table name.

Thanks !!

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Bobbak | last post by:
Hello All, I have these tables (lets call it ‘EmpCalls', ‘EmpOrders', and ‘Stats') that each contain the list of EmployeeIDs, I want to be able to create a Module in which I could call in my VB...
13
by: MLH | last post by:
I have a form with two controls: !! - combo box !! - text box A button on the form tries to run this SQL when clicked... INSERT INTO BodyMsgsSent (ToWhom, BodyText) SELECT DISTINCTROW !! AS...
10
by: MLH | last post by:
I have an A97 table with a Yes/No field named TowJob and a form bound to that table. The TowJob control on the form is bound to the same field. It is an option group with Yes and No bttns valued...
3
by: Kevin Rollo | last post by:
I'm playing with a generic routine to export data, the concept is to have a list of data driven templates defining what fields to output. Evaluating a simple variable field name in the function...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
4
by: Todd Perkins | last post by:
Hello all, surprisingly enough, this is my first newsgroup post, I usually rely on google. So I hope I have enough info contained. Thank you in advance for any help! Problem: I am getting...
10
by: gweasel | last post by:
What is the best way to apply a Validation Rule - or rather, where is the best place to put it? Is there an advantage to putting it on the field in the table vs setting the validation rule on the...
4
by: jtidwell | last post by:
I am getting this error after running my query The specified field could refer to more than one table listed in the FROM clause of your SQL statement. (Error 3079) my contractnum is a one to...
3
by: =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post by:
I'm attempting to use LINQ to insert a record into a child table and I'm receiving a "Specified cast is not valid" error that has something to do w/ the keys involved. The stack trace is: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.