Re: Error message-No value given for 1 or more parameters



anil wrote:
Hi all
I need help in two problems(Access 2000)
PROBLEM 1:
I am using parameterized query in vba and using this code(ADO)

Sub MResults()
Dim Conn1 As ADODB.Connection
Dim Cmd1 As ADODB.Command
Dim Param1 As ADODB.Parameter
Dim rst As ADODB.Recordset

Set Conn1 = New ADODB.Connection
Set rst = New ADODB.Recordset

Set Cmd1 = New ADODB.Command
Cmd1.ActiveConnection = CurrentProject.Connection
Cmd1.CommandText = "SELECT * FROM qryMResult WHERE
(((qryMResult.Month)= ?) AND ((qryMResult.Year)= ?)); "
Cmd1.CommandType = adCmdText

Set rst =
Cmd1.Execute(Parameters:=Array(Month(Forms!frmDhs!SelectMonth),
Year(Forms!frmDhs!SelectYear)))


The Command's Execute method expects three oprional parameters. It's been a
while, but I don't remember VBA supporting named parameters. Change this
statement to :

Dim arParms as Variant
arParms = Array(Month(Forms!frmDhs!SelectMonth), _
Year(Forms!frmDhs!SelectYear))
Set rst =Cmd1.Execute(,arParms)

When not supplying a value for the first argument in a method, you must
supply the comma to indicate that the frist argument is enot supplied and
the value being given applies to the second argument. When not supplying a
value for the final argument, the final comma can be left out.

<snip>

PROBLEM 2
The parameter query works good in DAO.Can we use any code either in
DAO or ADO or it makes any difference.I have used all other codes for
my database in ADO.

I don't understand the question.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.



Relevant Pages

  • Error message-No value given for 1 or more parameters
    ... I am using parameterized query in vba and using this code ... Dim Conn1 As ADODB.Connection ... Set rst = New ADODB.Recordset ...
    (microsoft.public.data.ado)
  • Re: Requerying ComboBox in NotInList event
    ... Response As Integer) ... Dim rst As Recordset ... Set rst = CurrentDb.OpenRecordset ... Dim lngBlankFound As Long ...
    (comp.databases.ms-access)
  • Re: Problem with multiselect list box code
    ... Set rst = db.OpenRecordset ... of the listbox but seperate fields on the form EventID & ... Dim frm As Form, ctl As Control ... Dim varItem As Variant ...
    (microsoft.public.access.formscoding)
  • Re: Requerying ComboBox in NotInList event
    ... Dim rst As Recordset ... Set rst = CurrentDb.OpenRecordset ... Dim lngBlankFound As Long ... It's like the name must have the comma or it won't work. ...
    (comp.databases.ms-access)
  • Re: Updating fields value via VBA
    ... Now you don't have to worry about updating the ScreenShot table. ... I set Combo0 ROWSOURCE to: ... Dim rst As DAO.Recordset ... Set rst = CurrentDb.OpenRecordset ...
    (microsoft.public.access.formscoding)