Error 'Too few parameters. Expected 1.'

J

Julia B

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
 

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