473,803 Members | 3,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cant Load query as recordset

25 New Member
Trying to load a query in Access 2003 as a recordset, returns error 3061, too few parameters, Expected 1.

Dim StrSQL As String
Dim rs As DAO.Recordset
Dim db As DAO.Database

StrSQL = "<some_SQL_Stat ement>"
Set db = CurrentDb()


Set rs = db.OpenRecordse t(StrSQL, dbOpenSnapshot)


also tried loading a query table as follows with the same results:-

Set rs = db.OpenRecordse t("My Query Table", dbOpenSnapshot)


I can load "My Query Table" using the same SQL statements via the standard Access environment OK.
Feb 13 '08 #1
3 2204
Stewart Ross
2,545 Recognized Expert Moderator Specialist
StrSQL = "SELECT [Product Table].[Product/Service], [Product Table].[Cost Sheet Path], [Product Table].[Check Sheet Path]FROM [Product Table]WHERE [Product Table].[Product/Service] =Forms!NCR!Prod uctCombo;"
Set db = CurrentDb()
I suspect your difficulty is in referring to the combo within the SQL string, instead of the value of the combo. The Where clause will fail as it stands. Try:

Expand|Select|Wrap|Line Numbers
  1. StrSQL = "SELECT [Product Table].[Product/Service], [Product Table].[Cost Sheet Path], [Product Table].[Check Sheet Path]FROM [Product Table]WHERE [Product Table].[Product/Service] = " & Forms!NCR!ProductCombo & ";"
Stewart
Feb 13 '08 #2
Codebug
25 New Member
Thanks, works ok now


I suspect your difficulty is in referring to the combo within the SQL string, instead of the value of the combo. The Where clause will fail as it stands. Try:

Expand|Select|Wrap|Line Numbers
  1. StrSQL = "SELECT [Product Table].[Product/Service], [Product Table].[Cost Sheet Path], [Product Table].[Check Sheet Path]FROM [Product Table]WHERE [Product Table].[Product/Service] = " & Forms!NCR!ProductCombo & ";"
Stewart
Feb 13 '08 #3
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Another thought: if you need to access the productcombo value when you run the query I find that Access is not consistent with references to form fields used as criteria. They can work OK as queries, yet fail when you try to open them using the OpenRecordSet method. Such references to form fields also fail if you convert a select query to a crosstab query.

I wrote a function to retrieve the field values which will work in SQL statements and in crosstab queries.

Expand|Select|Wrap|Line Numbers
  1. Public Function FormFieldValue(FormName As String, FieldName As String)
  2.     FormFieldValue = Forms(FormName).Controls(FieldName)
  3. End Function
Using it in the example you have given the SQL would be

Expand|Select|Wrap|Line Numbers
  1. StrSQL = "SELECT [Product Table].[Product/Service], [Product Table].[Cost Sheet Path], [Product Table].[Check Sheet Path]FROM [Product Table]WHERE [Product Table].[Product/Service] =FormFieldValue("NCR", "ProductCombo");"
It's another thing to try!

Stewart
Feb 13 '08 #4

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

Similar topics

20
10168
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
3
5395
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says there is a sample file called Ixtrasp.asp, but I could not find it in my system although I installed indexing service. I followed the steps in MSDN site to create a basic .asp query form (too long to post it here), but it always displays: No...
9
21653
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter the results in the grid. Say you filter the grid for records that have a certain condition set to "NO" (in this case a checkbox). In this scenario the search returns one result. If I then check the checkbox ("YES") and save it, I now get my message...
1
1479
by: WStoreyII | last post by:
I am trying to make a finances database. I have a master table which contains transaction header info and then a line details table. What i want is to make a reconcile query where i can see simply the date, account and posted (boolean field) from the transaction table and then a subquery with the total off all the line details for the transaction. this in itself is easy to set up. However I can not check if it is posted? If i go back...
5
1456
by: ZaphodBBB | last post by:
I have a form that is used just to review previously saved records.(1 record at a time). It also allows just a couple of fields to be updatable (in a given record)and resaved. I load all the text boxes in this this form simply by creating a recordset in the forms Load event procedure. It then populates the fields using... say . This works fine. But in the table that the recordsourse draws from there is only a customerID field and no...
9
3065
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. Below you will find the code I've written and the error that results. I'm hoping that someone can give me some direction as to what syntax or parameter is missing from the code that is expected by VBA. Overview: I'm trying to copy calculated...
3
1624
by: abie16 | last post by:
I'm creating a database for my company. Here we have errors form to calculate the errors done. The data entered in this form need to update into the errors table. This is my code but i'm getting error "Run-time error. Syntax error in INSERT INTO statement". Private Sub CmdSave_Enter() Dim strselect As String Dim strinsert As String Dim flag As Boolean Dim temp As String Dim msgval As Integer
2
7654
by: john0600 | last post by:
I'm writing a web service in .NET to work with Delphi clients. Delphi uses ADO so I want to convert the Dataset to a Recordset and vice- versa. It appears a Web Service cannot publish a web method with a Recordset return so I save the RecordSet to an XML string: SqlDataAdapter sa = new SqlDataAdapter("Select * FROM " + table , oConn); DataSet ds = new DataSet();
1
2093
by: Tomino | last post by:
Hi all, I have a sticky question, it's killing me for weeks so i hope to find the answer here. I have a query to filter records from a table. From these results I want to edit the records with recordset, to make a recordset works fine, but to edit one made me an old man ... :-( Can somebody please tell me how to edit records with a recordset? The meaning is that I load the records in a subform on my existing form where the user can edit the...
0
9566
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
10317
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
10300
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,...
0
9127
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7607
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
6844
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
5503
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
4277
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
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.