By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

Unable to Figure out -2147217904 error

P: 2
Access 2003 version

I get the above error when I execute the following code and have been unable to debug. Suggestions?

Expand|Select|Wrap|Line Numbers
  1.     Dim custrst As New ADODB.Recordset, strSQLStmt As String, strWhere As String
  2.  
  3.     strWhere = "(((tblCISInformation.customerFirstName)=" & searchFirstName & "))"
  4.  
  5.     strSQLStmt = "SELECT tblCISInformation.* FROM tblCISInformation WHERE " &  strWhere
  6.  
  7.     custrst.Open strSQLStmt, currentproject.Connection, _
  8.               adOpenForwardOnly
  9.  
  10.  

Thanks
Jan 4 '07 #1
Share this Question
Share on Google+
4 Replies


Expert 5K+
P: 8,434
Not sure about the specific error you reported, but I believe you need quotes around your customer name value. Try this (original line followed by modified one)...
Expand|Select|Wrap|Line Numbers
  1. strWhere = "(((tblCISInformation.customerFirstName)="  & searchFirstName & "))"
  2. strWhere = "(((tblCISInformation.customerFirstName)='" & searchFirstName & "'))"
Also, not that it really matters, but haven't you gone a bit overboard with the parentheses?
Jan 4 '07 #2

NeoPa
Expert Mod 15k+
P: 31,494
The parentheses were probably added by Access.
It does that to be ultra-safe rather than tidy :(
Jan 7 '07 #3

Expert 5K+
P: 8,434
The parentheses were probably added by Access.
It does that to be ultra-safe rather than tidy :(
Yeah, it goes absolutely berserk with them at times.
Jan 8 '07 #4

P: 2
Quotes worked like a charm. Thanks for your help.
Jan 9 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.