473,398 Members | 2,343 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,398 software developers and data experts.

Issue with Select not returning data to recordset

I am somewhat new to Access and I am trying to create a recordset to get data from the local access db. I get an error stating "Either BOF or EOF is True, or the current record has benn deleted..." I know the query I am selecting from has data as I run the same query in the query editor and get data. Please let me know what I am doing wrong. (Using Access 2003) The test function is listed below:

Expand|Select|Wrap|Line Numbers
  1. Public Function test1() As Integer
  2. On Error GoTo Err_test1
  3.  
  4. Dim rst1 As ADODB.Recordset
  5. Set rst1 = New ADODB.Recordset
  6.  
  7. strSQLStmt = "SELECT SystemAcronym, Control_ID, RA_Likelihood, RA_Impact, " & _
  8.              "RA_Risk, RA_Title, RA_Summary, RA_TandVAssessment, RA_Recommendation " & _
  9.              "FROM qryTechWriteUps;"
  10.  
  11.  
  12.     With rst1
  13.         .Source = strSQLStmt
  14.         .ActiveConnection = CurrentProject.Connection
  15.         .Open Options:=adCmdTxt
  16.         .MoveFirst
  17.     End With
  18.  
  19.     MsgBox rst1!SystemAcronym
  20.  
  21. Exit_test1:
  22.     Set rst1 = Nothing
  23.     Exit Function
  24.  
  25. Err_test1:
  26.     MsgBox Err.Number & "~" & Err.Description & "~" & Err.Source
  27.     Resume Exit_test1
  28.  
  29. End Function
  30.  
Sep 17 '07 #1
7 3826
FishVal
2,653 Expert 2GB
Hi, Chris.

Your code has to work as soon as query returns records.
I've not reproduced your situation.
Did you tried to run exactly the same string in query editor?
Sep 17 '07 #2
I did a copy and paste into the query editor, removed the quotes and line breaks and it returns 2 rows. I have been beating my head against the wall trying to figure this out.

Hi, Chris.

Your code has to work as soon as query returns records.
I've not reproduced your situation.
Did you tried to run exactly the same string in query editor?
Sep 17 '07 #3
FishVal
2,653 Expert 2GB
I did a copy and paste into the query editor, removed the quotes and line breaks and it returns 2 rows. I have been beating my head against the wall trying to figure this out.
Well.

First I thought that using default adOpenForwardOnly recordset cursor disables MoveFirst method. But it works fine. Moreover I've copypasted your code into my draft db, changed SQL string to match one of my table and it worked fine again.

So I don't have clues so far.
BTW disable error handling and determine there does code execution stop.
Sep 17 '07 #4
Figured out something: In my access query, I have a Criteria that uses 'Like 'TECH*' It returns rows if I execute that query. Now if I change it to LIKE 'TECH%' it does not return rows if I execute the query but the vb code gets records back. Any Idea as to why this is happening?


Well.

First I thought that using default adOpenForwardOnly recordset cursor disables MoveFirst method. But it works fine. Moreover I've copypasted your code into my draft db, changed SQL string to match one of my table and it worked fine again.

So I don't have clues so far.
BTW disable error handling and determine there does code execution stop.
Sep 17 '07 #5
FishVal
2,653 Expert 2GB
Figured out something: In my access query, I have a Criteria that uses 'Like 'TECH*' It returns rows if I execute that query. Now if I change it to LIKE 'TECH%' it does not return rows if I execute the query but the vb code gets records back. Any Idea as to why this is happening?
Much more clear now. :)

Access SQL dialect supports "*" wildcard.
"%" wildcard is being supported by ANSI SQL.

You may change SQL syntax to ANSI to run your query with "%" wildcard in Access (as is in builder, or as RecordSource/RowSource). Tools -> Options -> Tables/Queries -> SQL server compatible syntax (ANSI 92).

Or use DAO recordset in you code to open query with "*" wildcard.
Sep 17 '07 #6
Thank You, This is now working. It makes it tough to mixing ANSI 89 with ANSI 92
Much more clear now. :)

Access SQL dialect supports "*" wildcard.
"%" wildcard is being supported by ANSI SQL.

You may change SQL syntax to ANSI to run your query with "%" wildcard in Access (as is in builder, or as RecordSource/RowSource). Tools -> Options -> Tables/Queries -> SQL server compatible syntax (ANSI 92).

Or use DAO recordset in you code to open query with "*" wildcard.
Sep 17 '07 #7
FishVal
2,653 Expert 2GB
Thank You
Not for. You've solved it yourself
This is now working. It makes it tough to mixing ANSI 89 with ANSI 92
Add BUG2000 and Access2007 to the list. Both Microsoft(R). :)

You are welcome.

Regards,
Fish
Sep 17 '07 #8

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

Similar topics

14
by: CJM | last post by:
I have a query which produces different results in the Access query builder and in an ASP page (via ADO) An example of the query is: ----------------------------------------------------------...
6
by: Samuel Hon | last post by:
Hi I'm not sure what the best approach for this is: I have a stored procedure which I would like to use to return several output values instead of returning a recordset. CREATE PROCEDURE...
3
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
6
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
2
by: paulmitchell507 | last post by:
I think I am attempting a simple procedure but I just can't figure out the correct syntax. My asp (classic) page runs a SELECT query to obtain dates and ID's from 2 tables uSQL = "SELECT...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.