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

Problem with "Findfirst"

P: 53
Hi all
I'm a beginner in Recordsets so i have a problem with Recordsets!
When my application runs followed code,Run-Time Error '3070' occurs!
What is the problem?
Is there any wrong statement?

Thanks in advanced

Expand|Select|Wrap|Line Numbers
  1. Sub findrecord_bypkgno()
  2.     Dim rst As DAO.Recordset
  3.     Dim strCriteria As String
  4.  
  5.     strCriteria = "[Pack_no]= " & Me.searchpkg
  6.     Set rst = Me.RecordsetClone
  7.     rst.FindFirst (strCriteria)   'Run time error's yellow ribbon appear here
  8.     If rst.NoMatch Then
  9.         MsgBox "No entry found.", vbInformation
  10.     Else
  11.         Me.Bookmark = rst.Bookmark
  12.     End If
  13.  
  14.     Set rst = Nothing
  15.  
  16. End Sub
  17.  
Apr 7 '10 #1
Share this Question
Share on Google+
4 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
Since I don't know all the error codes by heart (thats my impolite way of saying please remember to post the full error description) I can only guess.

I think you simply need to remove the ( and ) around strCriteria.
If that doesn't work, make sure your giving it a proper strCriteria. Write a Msgbox strCriteria line into your code, before the Findfirst, so you can check that the strCriteria looks like its supposed to.

Also:
Is Pack_no a numeric value?
Apr 7 '10 #2

ADezii
Expert 5K+
P: 8,638
Expand|Select|Wrap|Line Numbers
  1. Dim rst As DAO.Recordset
  2. Dim strCriteria As String
  3.  
  4. strCriteria = "[Pack_no]= '" & Me.searchpkg & "'"
  5.  
  6. Set rst = Me.RecordsetClone
  7.  
  8. rst.FindFirst (strCriteria)
  9.  
  10. If rst.NoMatch Then
  11.   MsgBox "No entry found.", vbInformation
  12. Else
  13.   Me.Bookmark = rst.Bookmark
  14. End If
  15.  
  16. rst.Close
  17. Set rst = Nothing
Apr 7 '10 #3

P: 53
Thanks so That worked !
Apr 8 '10 #4

P: 53
Thanks
This is the solution:
strCriteria = "[Pack_no]= '" & Me.searchpkg & "'"
Apr 8 '10 #5

Post your reply

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