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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql Problems

Status
Not open for further replies.

fogal

Technical User
Aug 20, 2001
87
US
I am using the following sql to run an append query, but I get error messages. I have copied it out of design window in code, and replaced forms!etc!etc with end quotes and parameters etc... because these values are numbers

Please help!

strsql2 = "INSERT INTO tblAdCollectionFormDuplicateAds ( AdvertID, OperatorID, AlreadyDuplicate ) SELECT tblAdvDuplicates.AdvertID," & Forms!frmUserCapture!User & " AS Operator, 1 AS AlreadyDuplicate FROM (tblAdvDuplicates INNER JOIN tblAdverts ON tblAdvDuplicates.DuplID = tblAdverts.AdvertID) INNER JOIN tblAdverts AS tblAdverts_1 ON tblAdvDuplicates.AdvertID = tblAdverts_1.AdvertID WHERE (((tblAdverts.PublID) =" & [Forms]![frmAdvertQueries]![PublicationID] & ") And ((tblAdverts_1.PublID) =" & [Forms]![frmAdvertQueries]![RenewFrom] & ")) GROUP BY tblAdvDuplicates.AdvertID;"
 
It would be useful to tell us the error messages and at what action they are thrown.
 
error msg is : Extra ( in query expression '(((tbladverts.pubid)=38) And ((tbladverts_1.pubid)=))'
 
So I guess that
Code:
[Forms]![frmAdvertQueries]![RenewFrom]
is empty. can you run this query with the parametres hardcoded like:
Code:
strsql2 = "INSERT INTO tblAdCollectionFormDuplicateAds ( AdvertID, OperatorID, AlreadyDuplicate ) SELECT tblAdvDuplicates.AdvertID,1 AS Operator, 1 AS AlreadyDuplicate FROM (tblAdvDuplicates INNER JOIN tblAdverts ON tblAdvDuplicates.DuplID = tblAdverts.AdvertID) INNER JOIN tblAdverts AS tblAdverts_1 ON tblAdvDuplicates.AdvertID = tblAdverts_1.AdvertID WHERE (((tblAdverts.PublID) = 1) And ((tblAdverts_1.PublID) =1)) GROUP BY tblAdvDuplicates.AdvertID;"
It may return no results but tell me if it threw any errors.
 
Error Message Invalid Operation. The query will run from the original append query, but not via code. Not even if I do strsql2 = "select * from appendqueryname_etc.." I get the error message "An action query can not be run from a row source"
 
ok but have you tried running it but also making sure that
Code:
[Forms]![frmAdvertQueries]![RenewFrom]
has a value?
 
Even with a value I get the same error: Invalid Operation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top