473,394 Members | 1,645 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,394 software developers and data experts.

Too Few Parameters? I don't get it ... looks ok to me.

Hi, again.

I have a piece of code behind a form that is producing the following
error:

"Too few parameters. Expected 1."

However, it certainly looks like I have the parameters there. Here's
the code:

Set db = CurrentDb
strSQL = "SELECT tblDogs.ID as dogID FROM tblDogs " & _
"WHERE tblDogs.exhibitorID = " & Me!ID
Set rsd = db.OpenRecordset(strSQL)

The error occurs on the "Set rsd ..." statement. The db is defined as a
DAO.database and rsd is defined as a DAO.recordset.

Any ideas?

Thanks.
SueB

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #1
8 1445
The request for a parameter indicates that there is something Access does
not understand.

Is there a field named ID in tblDogs?
Is there a field named ExhibitorID (with no space)?

What type of field is ExhibitorID? If it is a Text type (not a Number type),
you need extra quotes:
"WHERE tblDogs.exhibitorID = """ & Me!ID & """;"

Is there a value in the text box ID at the time you receive the error?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Sue Bricker" <sb****@att.net> wrote in message
news:42**********@127.0.0.1...
Hi, again.

I have a piece of code behind a form that is producing the following
error:

"Too few parameters. Expected 1."

However, it certainly looks like I have the parameters there. Here's
the code:

Set db = CurrentDb
strSQL = "SELECT tblDogs.ID as dogID FROM tblDogs " & _
"WHERE tblDogs.exhibitorID = " & Me!ID
Set rsd = db.OpenRecordset(strSQL)

The error occurs on the "Set rsd ..." statement. The db is defined as a
DAO.database and rsd is defined as a DAO.recordset.

Any ideas?

Thanks.
SueB

Nov 13 '05 #2
Sue Bricker <sb****@att.net> wrote:
I have a piece of code behind a form that is producing the following
error:

"Too few parameters. Expected 1."

However, it certainly looks like I have the parameters there. Here's
the code:

Set db = CurrentDb
strSQL = "SELECT tblDogs.ID as dogID FROM tblDogs " & _
"WHERE tblDogs.exhibitorID = " & Me!ID
Set rsd = db.OpenRecordset(strSQL)

The error occurs on the "Set rsd ..." statement. The db is defined as a
DAO.database and rsd is defined as a DAO.recordset.


Hi Sue, a couple of things to check.

Is "ID" a text box? It's generally good practice to name controls with a
prefix, ie your text box would be named txtID so there would be no
ambiguous references.

Also, if txtID's data source type is "text" then you would need to use
quotation marks:

strSQL = "SELECT tblDogs.ID as dogID FROM tblDogs " & _
"WHERE tblDogs.exhibitorID = '" & Me!txtID & "';"

Regards,
Keith.
www.keithwilby.com
Nov 13 '05 #3


Allen,

Is there a field named ID in tblDogs?
YES. This is an autonumber (long int).

Is there a field named ExhibitorID (with no space)? YES
This is a long int in the tblDogs record. (connecting Dog record to
Exhibitor record)

What type of field is ExhibitorID? Long int

If it is a Text type (not a Number type),
you need extra quotes:
"WHERE tblDogs.exhibitorID = """ & Me!ID & """;"
Not a text field.

Is there a value in the text box ID at the time you receive the error?
Actually, I don't have an ID text box in the Exhibitor form. The form
is based on a query against the frmExhibitors. ID is the key of the
Exhibitor Record. I know that there is a valid value in me!ID because I
displayed it in debug mode in the 'Immediate window'. It's a valid
integer.

Now ... any ideas : )

Thanks.
Sue

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #4
No, that all looks right.

To debug it, add:
Debug.Print strSQL
just before the OpenRecordset line.
Run the code.
When it fails, look at what printed in the Immediate Window (Ctrl+G).

If that still looks right, try copying that, and pasting into SQL View of a
query. Does it work? Can you see what's wrong? Does the name of the
requested parameter now help you identify what name it does not recognise?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Sue Bricker" <sb****@att.net> wrote in message
news:42**********@127.0.0.1...


Allen,

Is there a field named ID in tblDogs?
YES. This is an autonumber (long int).

Is there a field named ExhibitorID (with no space)? YES
This is a long int in the tblDogs record. (connecting Dog record to
Exhibitor record)

What type of field is ExhibitorID? Long int

If it is a Text type (not a Number type),
you need extra quotes:
"WHERE tblDogs.exhibitorID = """ & Me!ID & """;"
Not a text field.

Is there a value in the text box ID at the time you receive the error?
Actually, I don't have an ID text box in the Exhibitor form. The form
is based on a query against the frmExhibitors. ID is the key of the
Exhibitor Record. I know that there is a valid value in me!ID because I
displayed it in debug mode in the 'Immediate window'. It's a valid
integer.

Now ... any ideas : )

Thanks.
Sue

Nov 13 '05 #5

Allen,

One more piece of information ...

The variable strSQL is defined as:

"SELECT tblDogs.ID as dogID FROM tblDogs WHERE tblDogs.exhibitorID =
329"

after the assignment statement (from debugging).

Thanks.
SueB
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #6

Keith,

"Is "ID" a text box? " No. ID is the autonumber key of the
tblExhibitor record. And YES you are right about naming conventions. I
try to name my variables inside procedures and modules using a
convention. However, I HAVE been laxed in my naming conventions (or
lack thereof) in record field names. So ... I agree with you.

Thanks for you input.

SueB

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #7

Allen,

ThankyouThankyouThankyou! Using the SQL view of Query was the thing I
needed. So, now my face is really RED. There is no field "exhibitorID"
in tblDogs. It is "exhibitor_ID". And I wrote this stuff!!!

Thanks very much.

SueB

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #8
Yep: we've all done that kind of thing, Sue.

And now you have learned another way to get Access to help you track down
what the problem is. It's a pretty powerful development environment.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Sue Bricker" <sb****@att.net> wrote in message
news:42**********@127.0.0.1...

Allen,

ThankyouThankyouThankyou! Using the SQL view of Query was the thing I
needed. So, now my face is really RED. There is no field "exhibitorID"
in tblDogs. It is "exhibitor_ID". And I wrote this stuff!!!

Thanks very much.

SueB

Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
by: J.R. | last post by:
Hi folks, The python can only support passing value in function call (right?), I'm wondering how to effectively pass a large parameter, such as a large list or dictionary? It could achieved...
2
by: Robert May | last post by:
We have a VB6 COM component that I don't have control over. All of the values are returned from method calls using byref parameters. They frequently break binary compatibility, in fact, there are...
7
by: UJ | last post by:
I got help from somebody here telling me how to run a DOS command using the process variable. Problem for me is that I need to be able to pass parameters to the program - multiple parameters at...
3
by: Jerry Houston | last post by:
In a winform application, I use worker threads to perform asynchronous tasks (e.g., mail merge with Word). The thread procs need to gather some user options from controls in the UI, and I know...
21
by: Dmitry Anikin | last post by:
I mean, it's very convenient when default parameters can be in any position, like def a_func(x = 2, y = 1, z): ... (that defaults must go last is really a C++ quirk which is needed for overload...
11
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
7
by: David Lowndes | last post by:
The following example illustrates something that's taken me a while to suss out (debugging someone else's code :( )... The crux is that the code compiles cleanly at W4, and the issue is that I'm...
7
by: keyser soze | last post by:
hi i have a stored proc, pointed by a synonym i wish to execute it vía: cmd.commandType= adStoredProc cmd.commandText= "s_MyStoredProc" cmd.parameters.refresh ---to get the collection the...
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: 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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.