error 3001

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi:

My database works fine last week, but this week when I open a form, or do
something else need to run this kind of code:
----------------------------------
strSQL = "SupplierCode = " & "'" & Me.SupplierCode & "'" 'build a SQL string.
DoCmd.OpenForm FormName:="frmProductsDataSheetView", view:=acFormDS,
whereCondition:=strSQL
---------------or----------------
strSQL = "SELECT ProductCode, NumOfPurchased, NumOfSold FROM Products Where
" _
& "ProductCode = '" & strMyProductCode & "'"
Set rst = dbs.OpenRecordset(strSQL)
---------------------------------

Will give me below error.
run-time error '3001'
Invalid argument

Why there was no problem at all to run this kind of code, but how these days
showing this? Do I miss something to update?

Really appreciate your help!

Thanks.

James
 
Try the following statement before the OpenForm or OpenRecordset statements:

Debug.Print strSQL

This will send the contents of strSQL to the immediate window. Does it look
correct? Does your data (the value for SupplierCode or strMyProductCode)
have an apostrophe in it?
 
Back
Top