parameter query in ADO

A

anil

hi all
I am trying to open a parameter query in ADO using code which is as
follows

Sub MResults()
Dim Conn1 As ADODB.Connection
Dim Cmd1 As ADODB.Command
Dim Param1 As ADODB.Parameter
Dim rst As ADODB.Recordset
' Create and Open Connection Object.
Set Conn1 = New ADODB.Connection
' Create Command Object.
Set Cmd1 = New ADODB.Command
Cmd1.ActiveConnection = Conn1
Cmd1.CommandText = "SELECT * FROM qryMResult WHERE month= ? , year=
? "
' Open Recordset Object.
Set Param1 =
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
End Sub

when I run this sub it gives no error but also do not print any records
in immediate window.Can anyone point the error where I am making the
mistake.
I tried to do it in DAO but the problem is same - no records or
display.
thanks
anil
 

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