473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Like Opertor is not working in MS acces-Retun error code 3021 -eith EOF OR BOF is tru

Dar team

need u r help

I am new to aceess . I am writign a query in access for finding the last name mathcing with criteria using Like operator.
Expand|Select|Wrap|Line Numbers
  1. selct a,b,c from Table1 where last  name like '*"&  Paramter value &"*'
When in debug mode I can see teh in immediate window teh query and when i put this query in query window in access it is returning the
data also which is very good

but in Actual from where I am using a function
Expand|Select|Wrap|Line Numbers
  1. set rs = getlastname(LastName)--(Last name is the Paramet er in above query)
The function is as follows

Expand|Select|Wrap|Line Numbers
  1. Function getlastname(lastnamyName As String) As ADODB.Recordset
  2.     Dim rs As ADODB.Recordset
  3.     Dim strsql As String
  4.     Dim da As New DABase
  5.  
  6.  
  7.     strsql = "SELECT *"
  8.     strsql = strsql & " FROM tables1  "
  9.     strsql = strsql & " WHERE (((lastname) like  ""*" & lastame & "*"")) ;"
  10.  
  11.     da.openConnection
  12.     da.CommandText = strsql
  13.     Set getlastname= da.openRecordset
  14.     Set da = Nothing
  15.  
  16. End Function

after completion of this fun.. I agin come in my main form where this fn has een written
Expand|Select|Wrap|Line Numbers
  1. set rs = getlastname(LastName)-
after htis line rs.recordcount showing me as zero ??? so that is te reason run time error 3021 is coming..

Funny thing is if I remove liek operator it is wrking finme.

Request u r help
Jan 29 '10 #1
2 1819
Stewart Ross
2,545 Expert Mod 2GB
Hi, and Welcome to Bytes!

If you have copied and pasted your function accurately then you have a mis-spelt variable name in your LIKE clause:

Expand|Select|Wrap|Line Numbers
  1. strsql = strsql & " WHERE (((lastname) like ""*" & lastame & "*"")) ;"
should be

Expand|Select|Wrap|Line Numbers
  1. strsql = strsql & " WHERE (((lastname) like ""*" & lastname & "*"")) ;"
If this is the case, it also means that you are not using the OPTION EXPLICIT directive at the top of your code in the VBA Editor. If you were, the editor would itself pick up that you have an undeclared variable (which is what it will treat your misnamed variable as), in turn allowing you to see and fix the error before it causes you difficulties.

I may be wrong, as there are many, many spelling errors in your post and in the code (including the parameter name, which in your function is listed as lastnamyName). If you have copied in code by hand please don't - give us the actual code you are using, not a mis-spelt version of it. Saves a lot of our time!

-Stewart
Jan 29 '10 #2
@Stewart Ross Inverness
team,

Sorry for mis-spelling, In the code it is right, now again I have searced on the net. For DAO we need to put * & for ADO we can use %.

Now it is wokring. Thanks for u r help Stewart.

Sorry for the inconvenince

Regds
Amogh
Jan 29 '10 #3

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

Similar topics

2
by: Mike Fisher | last post by:
I'm seeing an error when I try to run/debug a web service. Although it doesn't happen every time, it does occur more than half of the times I hit F5. It appears to be returned by the the JIT...
2
by: Janna Deegan | last post by:
Hello all, First off, if there is a better place to post for an answer to this question, please feel free to point me there. I have some very strange behavior happening with my System.web.mail...
3
by: Hamilton | last post by:
Hi there, I've seen this error appear a few times in newsgroups but unfortunately I haven't found one that actually provides a solution. I'm basically deploying a new website into an area at a...
1
by: Razzie | last post by:
Hi all, I was working on a little project, worked fine, but now all of a sudden I get: The compiler failed with error code -1073741502 as an error message (when running the site, not...
3
by: ralphdepping | last post by:
Trying to get moinmoin wiki working on Windows 2000 using IIS and python. I get the following error when trying to view the start page after insalling moinmoin and python - key error seems to be...
1
by: delusion7 | last post by:
Trying to create a table and insert records from a webform and I keep getting this message: "Successfully created the registration table. Unable to execute the query. Error code...
1
by: jyoti202 | last post by:
Hi, Need help for this as i have been looking for it but could not get any results. We are using java as front end and DB2 as backend, i m getting the exception while executing a particular...
1
by: kigoobe | last post by:
Hi friends, I'm having three queries that works perfectly ... SELECT ib.id as id, ib.titre as title, ib.date_expire as date_fin, ib.created_at as date_creation, eb.content as content, '' FROM...
0
by: t0rmed | last post by:
I am currently creating my project for visual basic, which is particularly a database. However, error code 3021 shows up when I click delete even though I do not have a database. How could I solve...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.