Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Access
3rdpartyusrgrp
access
activexcontrol
adp.sqlserver
commandbarsui
conversion
dataaccess.pages
developers.toolkitode
devtoolkits
externaldata
forms
formscoding
gettingstarted
internet
interopoledde
macros
modulescoding
modulesdaovba
modulesdaovba.ado
multiuser
odbcclientsvr
queries
replication
reports
security
setupconfig
tablesdbdesign
  
 
date: Thu, 12 Jun 2008 00:58:01 -0700,    group: microsoft.public.access.modulesdaovba.ado        back       


Error 'Too few parameters. Expected 1.'   
Hi, excuse the cross posting. I did post this in Forms Coding, but didn't get 
a response so I think I may have posted in the wrong place (seeing as my 
error occurs when using ADO). My apologies, I wouldn't normally post twice! 
Anyway I've got a strange problem.

I've got a form 'EditPartNumbers' where a user can filter the records by 
selecting a value in a combo box, which in turn populates a value in a hidden 
text box, 'txtFindHidden'. The form is then supposed to change it's 
datasource to a query 'PartNumbersFine_EditForm', which has a parameter in 
it's RecordID field which is [Forms]![EditPartNumber]![txtFindHidden].

If I select a record from the combo box and run the query directly from 
Access it works fine, but if I try and run it through the following code, I 
get an error:

'Run-time error -2147217904 (80040e10): Too few parameters. Expected 1.'

Here's the code:

 Dim db As ADODB.Connection
    Dim rs As New ADODB.Recordset
    Set db = CurrentProject.Connection
    
    'firstly get a recordset to check if there are any records
    If formMode = "New" Then
        rs.Open "PartNumbersNew_EditForm", db, adOpenKeyset, 
adLockOptimistic, adCmdTableDirect
    Else
        'if the form isn't showing just new parts then get the recordset 
depending on whether it's a find part or not
        If findPart = "" Then
            rs.Open "PartNumbersAll_EditForm", db, adOpenKeyset, 
adLockOptimistic, adCmdTableDirect
        Else
'this is where it stalls!            
rs.Open "PartNumbersFind_EditForm", db, adOpenKeyset, adLockOptimistic, 
adCmdTableDirect
        End If
    End If

I've searched and it would seem that the most common problem is a syntax 
one, but I can't understand that it in this case.

Any ideas?

Thanks
Julia
date: Thu, 12 Jun 2008 00:58:01 -0700   author:   Julia B

Re: Error 'Too few parameters. Expected 1.'   
Hi,
you have to supply parameter to your query and set it value to 
[Forms]![EditPartNumber]![txtFindHidden].

see Parameters Collection in online help

-- 
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

"Julia B"  wrote in message 
news:275129D4-87BD-421A-847E-4583D12F1066@microsoft.com...
> Hi, excuse the cross posting. I did post this in Forms Coding, but didn't 
> get
> a response so I think I may have posted in the wrong place (seeing as my
> error occurs when using ADO). My apologies, I wouldn't normally post 
> twice!
> Anyway I've got a strange problem.
>
> I've got a form 'EditPartNumbers' where a user can filter the records by
> selecting a value in a combo box, which in turn populates a value in a 
> hidden
> text box, 'txtFindHidden'. The form is then supposed to change it's
> datasource to a query 'PartNumbersFine_EditForm', which has a parameter in
> it's RecordID field which is [Forms]![EditPartNumber]![txtFindHidden].
>
> If I select a record from the combo box and run the query directly from
> Access it works fine, but if I try and run it through the following code, 
> I
> get an error:
>
> 'Run-time error -2147217904 (80040e10): Too few parameters. Expected 1.'
>
> Here's the code:
>
> Dim db As ADODB.Connection
>    Dim rs As New ADODB.Recordset
>    Set db = CurrentProject.Connection
>
>    'firstly get a recordset to check if there are any records
>    If formMode = "New" Then
>        rs.Open "PartNumbersNew_EditForm", db, adOpenKeyset,
> adLockOptimistic, adCmdTableDirect
>    Else
>        'if the form isn't showing just new parts then get the recordset
> depending on whether it's a find part or not
>        If findPart = "" Then
>            rs.Open "PartNumbersAll_EditForm", db, adOpenKeyset,
> adLockOptimistic, adCmdTableDirect
>        Else
> 'this is where it stalls!
> rs.Open "PartNumbersFind_EditForm", db, adOpenKeyset, adLockOptimistic,
> adCmdTableDirect
>        End If
>    End If
>
> I've searched and it would seem that the most common problem is a syntax
> one, but I can't understand that it in this case.
>
> Any ideas?
>
> Thanks
> Julia
>
date: Fri, 13 Jun 2008 09:44:21 +0400   author:   Alex Dybenko

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us