473,800 Members | 3,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why does this query fail in ADODB.recordset ?

157 New Member
I have query this to filter the posts i want to work with, it is called "MAIN ompakkingskø baklager Gemba" and the sql is this:

Expand|Select|Wrap|Line Numbers
  1. SELECT [LOK Loksummer].Varenr, [LOK Loksummer].Lokasjon AS Baklager, [LOK Loksummer].[Antall tabletter], Left([lokasjon],2) AS c
  2. FROM [LOK Loksummer]
  3. WHERE ((([LOK Loksummer].Lokasjon) Like "*Gemba*") AND ((Left([lokasjon],2))="01" Or (Left([lokasjon],2))="02" Or (Left([lokasjon],2))="03" Or (Left([lokasjon],2))="04" Or (Left([lokasjon],2))="05" Or (Left([lokasjon],2))="06" Or (Left([lokasjon],2))="07" Or (Left([lokasjon],2))="08" Or (Left([lokasjon],2))="09" Or (Left([lokasjon],2))="10" Or (Left([lokasjon],2))="11" Or (Left([lokasjon],2))="12" Or (Left([lokasjon],2))="13" Or (Left([lokasjon],2))="14" Or (Left([lokasjon],2))="15" Or (Left([lokasjon],2))="16" Or (Left([lokasjon],2))="17" Or (Left([lokasjon],2))="18"));
I always use ADODB.recordset to work with data. Either to insert data in forms or in tables.

When i open the query by clicking on the query it shows exactly the post it is supposed to show, but when i open it with ADODB it gives an error

Expand|Select|Wrap|Line Numbers
  1. Dim rst As New ADODB.Recordset
  2. With rst
  3.     .Open "MAIN ompakkingskø baklager Gemba", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
  4.         Do Until .EOF
  5.         MsgBox !baklager
  6.         .MoveNext
  7.         Loop
  8.     .Close
  9. End With
  10. Set rst = Nothing
This DAO is working fine:
Expand|Select|Wrap|Line Numbers
  1. Dim rs As dao.Recordset
  2.  
  3. Set rs = CurrentDb.OpenRecordset("MAIN ompakkingskø baklager Gemba")
  4. While Not rs.EOF
  5. MsgBox rs!baklager
  6. rs.MoveNext
  7. Wend
  8. rs.Close
  9. Set rs = Nothing
  10.  
Jul 24 '09 #1
1 2482
ADezii
8,834 Recognized Expert Expert
@MrDeej
Try a change in Syntax, and see what happens:
Expand|Select|Wrap|Line Numbers
  1. Dim rst As New ADODB.Recordset
  2.  
  3. With rst
  4.   .Source = "MAIN ompakkingskø baklager Gemba"
  5.   .ActiveConnection = CurrentProject.Connection
  6.   .CursorType = adOpenForwardOnly
  7.   .LockType = adLockReadOnly
  8.     .Open
  9.  
  10.   Do While Not .EOF
  11.     MsgBox !baklager
  12.       .MoveNext
  13.   Loop
  14. End With
  15.  
  16. rst.Close
  17. Set rst = Nothing
What is the Error you are receiving if the previous does not work?

You should also consider modifying part of your WHERE Clause:
Expand|Select|Wrap|Line Numbers
  1. AND Left$([Lokasjon],2) In ("01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18")
Jul 24 '09 #2

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

Similar topics

5
2115
by: BP | last post by:
I get the following error: Error Type: Microsoft VBScript runtime (0x800A01A8) Object required: '' /myweb4/authorised_user_page.asp, line 70 and line 70 of my code is: <% rsCheckUser1.Open strSQL1, strcon1 %> Here is the full code:
9
11777
by: shank | last post by:
Per a previous suggestion, I'm trying to use a parametized query in Access 2002. The query functions properly in Access. Now I'm trying to call it from ASP. I'm using code I found at http://www.xefteri.com/articles/apr302002/default.aspx and trying to adjust for my needs. I'm getting this error. The query is there and functioning. It appears that I'm not connecting. Can I get some more insight? thanks! ------------------------------...
2
1594
by: Auddog | last post by:
I have created a database request page (wahooo - new to asp and it works) and everything is great. Now I'm creating a second page and want to know if I'm able to make two different queries on one page. I want to be able to create one query that uses a Request.QueryString from a URL and then use one of the returned values from that query to create another query on the same page. I hope that make sense. Here is the database connection...
2
2035
by: David C. Barber | last post by:
upsized an MDB to ADP/SQL Server 2000 under Access 2000. All the DAO code that I've changed to ADO code is working fine, HOWEVER the form Record Source itself does not seem willing to return data. I've set the Record Source to both the query, and the SQL contained within the query, and although the system pauses long enough to have gone out and retrieved the data, I can't see it. The form itself remains gray. In addition: ...
0
3032
by: totierne | last post by:
comp.databases.ms-access, I want to know how to use Oracle views with session variables in Access. The parameterised views in access, are migrated to views with per session variables. The open questions: How to display a resultset
2
3048
by: barret bonden | last post by:
(closest newsgroup I could find) Error Type: ADODB.Recordset (0x800A0CB3) Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype. /asp_data3_add.asp, line 30 <% 'Dimension variables Dim adoCon 'Holds the Database Connection Object
5
3754
by: Hexman | last post by:
I've come up with an error which the solution eludes me. I get the error: >An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in HRTest.exe > >Additional information: Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype. It occurs when I attempt to add a new record. I've stripped out much of the code, leaving the pertinent (I hope) info. ...
1
10484
by: Mayhem05 | last post by:
I have an Access 2003 database that I need to write some VBA code for to populate a table. The table is based on a query I have built in Access queries. Right now I have 2 parameters that are passed to the query from a form (DateFrom and DateTo). When I open the form and populate the variables (DateFrom and DateTo) then open the query it works fine. My problem is that I need to do this from VBA coding and pass the 2 parameters to the...
0
1025
by: SMasterson | last post by:
Hi all, I am trying to execute code to insert records from an Access 2002 Xtab query to a remote Sql_Server table. I keep getting a random problem where the Access query doesn't complete before the Sql_Server insert begins. I have tried locks, state checking and indexing. It is almost like the code is running too fast for the process to be completed. In the example below, I get the same null result repeatedly for one field in one record. ...
0
9553
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10281
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10256
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7584
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6824
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4152
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2953
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.