Error message-No value given for 1 or more parameters



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)))

Do Until rst.EOF
Debug.Print rst("LocationName"), rst("Parameter")
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set Cmd1 = Nothing
End Sub

But I am getting this message - No value given for one or more
parameters.
On net and book code seems similar but I am not able to find where is
the error.
Can some one help?

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.

Thanks
anil

.



Relevant Pages

  • Re: 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)