SQL HELP Seems Simple

  • Thread starter Thread starter Brandon Johnson
  • Start date Start date
B

Brandon Johnson

Can anyone help me with this? Ive done this before but for some odd
reason its throwing me a runtime '2001' error. Its pretty urgent that i
get this resolved before tom. so if anyone can help, much appreciation.

promotetemp: a string that is chosen from a drop down to choose what
table to get to.
criteria: a string that has a list of upcs to search for in the table
chosen. format: ('__','__',etc)

Me.frmPromote.Form.RecordSource = "SELECT UPCCase, UPCItem, SVDCName,
SVItemCd, SVBrand, SVDescription, SVPack, SVSize, SVStatus, WeekFcst,
VendorPkCost, SVSell FROM z" & promotetemp & " WHERE UPCCase IN " &
criteria & ";"
 
Are there any spaces in what's in promotetemp? If so, try:

Me.frmPromote.Form.RecordSource = "SELECT UPCCase, UPCItem, SVDCName,
SVItemCd, SVBrand, SVDescription, SVPack, SVSize, SVStatus, WeekFcst,
VendorPkCost, SVSell FROM [z" & promotetemp & "] WHERE UPCCase IN " &
criteria & ";"

Otherwise, try putting the string into a variable and printing the variable
to the Immediate window (Ctrl-G). Does the SQL look correct? Does it run
when you copy it into a query?
 
Thats what came of it:
SELECT * FROM [zClorox] WHERE UPCCase IN ('4460001683');

everything looks correct to me.(that z is suppose to be there btw, its
how i named all my tables for ease). Does anyhting stand out to you?
Are there any spaces in what's in promotetemp? If so, try:

Me.frmPromote.Form.RecordSource = "SELECT UPCCase, UPCItem, SVDCName,
SVItemCd, SVBrand, SVDescription, SVPack, SVSize, SVStatus, WeekFcst,
VendorPkCost, SVSell FROM [z" & promotetemp & "] WHERE UPCCase IN " &
criteria & ";"

Otherwise, try putting the string into a variable and printing the variable
to the Immediate window (Ctrl-G). Does the SQL look correct? Does it run
when you copy it into a query?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Brandon Johnson said:
Can anyone help me with this? Ive done this before but for some odd
reason its throwing me a runtime '2001' error. Its pretty urgent that i
get this resolved before tom. so if anyone can help, much appreciation.

promotetemp: a string that is chosen from a drop down to choose what
table to get to.
criteria: a string that has a list of upcs to search for in the table
chosen. format: ('__','__',etc)

Me.frmPromote.Form.RecordSource = "SELECT UPCCase, UPCItem, SVDCName,
SVItemCd, SVBrand, SVDescription, SVPack, SVSize, SVStatus, WeekFcst,
VendorPkCost, SVSell FROM z" & promotetemp & " WHERE UPCCase IN " &
criteria & ";"
 
Error 2001 ("You canceled the previous operation.") is the error that's
issued if you've mistyped either the table or field name. (Yeah, I know it's
not intuitive...)

On the other hand, it looks as though you might have separate tables for
each product. That's a mistake: you should have a single table, with an
additional field to identify the product.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Brandon Johnson said:
Thats what came of it:
SELECT * FROM [zClorox] WHERE UPCCase IN ('4460001683');

everything looks correct to me.(that z is suppose to be there btw, its
how i named all my tables for ease). Does anyhting stand out to you?
Are there any spaces in what's in promotetemp? If so, try:

Me.frmPromote.Form.RecordSource = "SELECT UPCCase, UPCItem, SVDCName,
SVItemCd, SVBrand, SVDescription, SVPack, SVSize, SVStatus, WeekFcst,
VendorPkCost, SVSell FROM [z" & promotetemp & "] WHERE UPCCase IN " &
criteria & ";"

Otherwise, try putting the string into a variable and printing the
variable
to the Immediate window (Ctrl-G). Does the SQL look correct? Does it run
when you copy it into a query?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Brandon Johnson said:
Can anyone help me with this? Ive done this before but for some odd
reason its throwing me a runtime '2001' error. Its pretty urgent that i
get this resolved before tom. so if anyone can help, much appreciation.

promotetemp: a string that is chosen from a drop down to choose what
table to get to.
criteria: a string that has a list of upcs to search for in the table
chosen. format: ('__','__',etc)

Me.frmPromote.Form.RecordSource = "SELECT UPCCase, UPCItem, SVDCName,
SVItemCd, SVBrand, SVDescription, SVPack, SVSize, SVStatus, WeekFcst,
VendorPkCost, SVSell FROM z" & promotetemp & " WHERE UPCCase IN " &
criteria & ";"
 
Back
Top