too few parameters

K

Karen

I have the following code that I'm trying to use to 'view' one record of a
SQL table that I've linked to with Access 2002. This code is behind a
button on a form. On the form I enter a value in a control named custno.
When I click the button I get an error that says 'Too few parameters.
Expected 1." In the SQL table, filler_0001 is a text field.
----------------
Dim rst As Recordset
Dim MyWksp As Workspace
Dim MyDB As Database
Dim MySQL As String, MyCriteria As String

Set MyWksp = DBEngine.Workspaces(0)
Set MyDB = MyWksp.Databases(0)

MySQL = "SELECT * FROM dbo_oeprcfil_sql WHERE
dbo_oeprcfil_sql.[filler_0001] ="
MyCriteria = Me!Custno

Set rst = MyDB.OpenRecordset(MySQL & MyCriteria, dbOpenForwardOnly)

If Not rst.EOF Then
MsgBox ("CustomerNumber/Code = ")
------------------
If I change the MyCriteria line to (and add a single quote after the last
equal sign in the MySql statement)
MyCriteria = Me!Custno & "'"
I get an error 'Type Mismatch'
The value I'm entering in the control on the form is 0000000021923920-M

Help!!!

Thank you (yet again!)
Karen
 
P

PC Datasheet

Try this:
MySQL = "SELECT * FROM dbo_oeprcfil_sql WHERE
dbo_oeprcfil_sql.[filler_0001] ='"
MySQL = MYSQL & Me!CustNo & "'"
Set rst = MyDB.OpenRecordset(MySQL, dbOpenForwardOnly)

Note 1: Added single quote before double quote in first MYSQL line
Note 2: You don't need the MyCriteria line
Note 3: At the end of the second MySQL line is a single quote between two
double quoyes


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com

If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!
 
S

StopThisAdvertising

PC Datasheet said:
If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!

To the OP: Beware of this guy!!

Steve just does *not* care about the newsgroups. He has *no ethics at all*.
Steve *only* cares about making *money*, and he acts as if the groups are his private hunting ground.

-- He abuses this group and others for job-hunting and advertising over and over again
-- He is insulting lots of people here when they ask him to stop this
-- He posted as Steve, Ron, Tom, Rachel, Kathy, Kristine, Heather and ??? while asking questions
(the latest 'star's': 'Access Resource' and Tom (e-mail address removed) and Andy)
-- He tries to sell a CD ($125,--) with FREE code he gathered from these groups here
-- There even has been a 'Scam-alert' about him which has been explained recently in the thread 'To all':
http://groups.google.com/group/comp.databases.ms-access/msg/46038ba2954261f9?hl=en
-- Also recently it became clear that he has been spamming innocent people asking questions:
http://groups.google.com/group/comp.databases.ms-access/msg/4f76d0ed3e5f58ad?hl=en

So why would ANYBODY ever trust a person like him and hire him?
********************************************************

Explanation and more links on this answer:
http://home.tiscali.nl/arracom/stopsteve.html

Arno R
 
K

Karen

I have already tried this, as noted below the code section of my original
note. This code gives me a 'Type Mismatch' error.

Anyone else have an idea?


Karen



PC Datasheet said:
Try this:
MySQL = "SELECT * FROM dbo_oeprcfil_sql WHERE
dbo_oeprcfil_sql.[filler_0001] ='"
MySQL = MYSQL & Me!CustNo & "'"
Set rst = MyDB.OpenRecordset(MySQL, dbOpenForwardOnly)

Note 1: Added single quote before double quote in first MYSQL line
Note 2: You don't need the MyCriteria line
Note 3: At the end of the second MySQL line is a single quote between two
double quoyes


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com

If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!


Karen said:
I have the following code that I'm trying to use to 'view' one record of a
SQL table that I've linked to with Access 2002. This code is behind a
button on a form. On the form I enter a value in a control named custno.
When I click the button I get an error that says 'Too few parameters.
Expected 1." In the SQL table, filler_0001 is a text field.
----------------
Dim rst As Recordset
Dim MyWksp As Workspace
Dim MyDB As Database
Dim MySQL As String, MyCriteria As String

Set MyWksp = DBEngine.Workspaces(0)
Set MyDB = MyWksp.Databases(0)

MySQL = "SELECT * FROM dbo_oeprcfil_sql WHERE
dbo_oeprcfil_sql.[filler_0001] ="
MyCriteria = Me!Custno

Set rst = MyDB.OpenRecordset(MySQL & MyCriteria, dbOpenForwardOnly)

If Not rst.EOF Then
MsgBox ("CustomerNumber/Code = ")
------------------
If I change the MyCriteria line to (and add a single quote after the last
equal sign in the MySql statement)
MyCriteria = Me!Custno & "'"
I get an error 'Type Mismatch'
The value I'm entering in the control on the form is 0000000021923920-M

Help!!!

Thank you (yet again!)
Karen
 
P

PC Datasheet

Did you put a single quote then a double quote after the equal sign at the
end of the MySQL line?

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com

If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!




Karen said:
I have already tried this, as noted below the code section of my original
note. This code gives me a 'Type Mismatch' error.

Anyone else have an idea?


Karen



PC Datasheet said:
Try this:
MySQL = "SELECT * FROM dbo_oeprcfil_sql WHERE
dbo_oeprcfil_sql.[filler_0001] ='"
MySQL = MYSQL & Me!CustNo & "'"
Set rst = MyDB.OpenRecordset(MySQL, dbOpenForwardOnly)

Note 1: Added single quote before double quote in first MYSQL line
Note 2: You don't need the MyCriteria line
Note 3: At the end of the second MySQL line is a single quote between
two
double quoyes


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com

If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
Need a month calendar or 7 day calendar? Need appointment scheduling?
Need
room reservations scheduling? Need employee work scheduling? Contact me!


Karen said:
I have the following code that I'm trying to use to 'view' one record of a
SQL table that I've linked to with Access 2002. This code is behind a
button on a form. On the form I enter a value in a control named custno.
When I click the button I get an error that says 'Too few parameters.
Expected 1." In the SQL table, filler_0001 is a text field.
----------------
Dim rst As Recordset
Dim MyWksp As Workspace
Dim MyDB As Database
Dim MySQL As String, MyCriteria As String

Set MyWksp = DBEngine.Workspaces(0)
Set MyDB = MyWksp.Databases(0)

MySQL = "SELECT * FROM dbo_oeprcfil_sql WHERE
dbo_oeprcfil_sql.[filler_0001] ="
MyCriteria = Me!Custno

Set rst = MyDB.OpenRecordset(MySQL & MyCriteria, dbOpenForwardOnly)

If Not rst.EOF Then
MsgBox ("CustomerNumber/Code = ")
------------------
If I change the MyCriteria line to (and add a single quote after the last
equal sign in the MySql statement)
MyCriteria = Me!Custno & "'"
I get an error 'Type Mismatch'
The value I'm entering in the control on the form is 0000000021923920-M

Help!!!

Thank you (yet again!)
Karen
 
K

Keith W

Karen said:
I have already tried this, as noted below the code section of my original
note. This code gives me a 'Type Mismatch' error.

Anyone else have an idea?
Karen,

You seem to have opened a recordset but not moved to a record. Might this
be the problem?

eg:

Set rst = MyDB.OpenRecordset(MySQL & MyCriteria, dbOpenForwardOnly)
rst.MoveFirst

etc

Keith.
www.keithwilby.com
 
D

Douglas J Steele

Keith W said:
Karen,

You seem to have opened a recordset but not moved to a record. Might this
be the problem?

eg:

Set rst = MyDB.OpenRecordset(MySQL & MyCriteria, dbOpenForwardOnly)
rst.MoveFirst

etc

Actually the problem was that she wasn't disambiguating her declaration of
rst so that she was getting an ADO recordset.

Unfortunately, she had more than one thread going on this topic, so a number
of people ended up spending time on it.
 
K

Karen

Sorry about the multiple threads. I was so tied up trying to fix this and
then there was the message from PCDatasheet and StopThisAdvert.. and I was
afraid my original inquiry was lost so I reposted. Douglas was able to help
me on my second post and all is well.

Thanks to everyone who answers my pleas for help. I've learned much from the
newsgroups.

Karen
 
P

PC Datasheet

Doug,

Here's a good example of what Arno R and his band of dimwiteers are
causing ---

<Sorry about the multiple threads. I was so tied up trying to fix this and
then there was the message from PCDatasheet and StopThisAdvert.. and I was
afraid my original inquiry was lost so I reposted. >

Steve
 
J

John Marshall, MVP

PC Datasheet said:
Doug,

Here's a good example of what Arno R and his band of dimwiteers are
causing ---

Sorry steve, I don't think Doug will be impressed with your logic (or
professionalism).

John... Visio MVP
 
P

PC Datasheet

Doug,

You better get right over to CDMA. John Marshall is saying that it is okay
for anyone to out their URL in the newsgroups to advertise their merchandise
or service.

Steve
 
J

John Marshall, MVP

PC Datasheet said:
Doug,

You better get right over to CDMA. John Marshall is saying that it is okay
for anyone to out their URL in the newsgroups to advertise their
merchandise or service.

Steve

Brilliant steve, misquoting as usual. You said a poster was advertising in
CDMA and I pointed out he was not. The advertising was on his webpage that
was listed as a URL in his sigline.

John... Visio MVP

PS: Sure looks like Doug has a URL in his sigline.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top