Re: Error message-No value given for 1 or more parameters
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Mon, 25 Sep 2006 06:40:32 -0400
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>
I don't understand the question.
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.
--
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"
.
- Follow-Ups:
- References:
- Prev by Date: Error message-No value given for 1 or more parameters
- Next by Date: Re: Recordset used in Select/Option pick list
- Previous by thread: Error message-No value given for 1 or more parameters
- Next by thread: Re: Error message-No value given for 1 or more parameters
- Index(es):
Relevant Pages
|
|