Passing parameters

  • Thread starter Thread starter KathyJ
  • Start date Start date
K

KathyJ

I trying to pass 3 parameters to an append query.
The first 2 are dates that are added when the data is
appended to the datle. The 3rd parameter is the criteria
parameter. When I try and run the query from code,I get
the following error message,
"Parameter object is improperly defined. Inconsistant or
imcomplete information was provided."

Set prmEndDate = cmd.CreateParameter("CEndDate",
adDate, , , varCEndDate)
cmd.Parameters.Append prmEndDate

Set prmCust = cmd.CreateParameter("[PCust", , , ,
strCust).

I know it has something to do with the fact that the 3rd
and problem parameter is criteria, but other than that, I
don't have any idea.

Any clues???
Thanks
 
"Parameter object is improperly defined. Inconsistant or
imcomplete information was provided."

Set prmEndDate = cmd.CreateParameter("CEndDate",
adDate, , , varCEndDate)
cmd.Parameters.Append prmEndDate

Set prmCust = cmd.CreateParameter("[PCust", , , ,
strCust).

I know it has something to do with the fact that the 3rd
and problem parameter is criteria, but other than that, I
don't have any idea.

If this is copied from your code, there's no closing bracket after
[PCust in the first argument...
 
no that was a typo on my part.
'2nd parm
Set prmEndDate = cmd.CreateParameter("CEndDate",
adDate, , , varCEndDate)
cmd.Parameters.Append prmEndDate
'problem parm
Set prmCust = cmd.CreateParameter("PCust", , , ,
strCust)
cmd.Parameters.Append prmCust
and here's the query
PARAMETERS CBegDate DateTime, CEndDate DateTime, PCust
Value;
INSERT INTO UBILL_ARCHIVED_BILLING_E_TRANS (
COMPLEX_NUMBER, COMP_BEG_DATE, COMP_END_DATE )
SELECT UBILL_CURRENT_BILLING_E_TRANS.COMPLEX_NUMBER,
[CBegDate] AS Comp_Beg_Date, [CEndDate] AS Comp_End_Date
FROM UBILL_CURRENT_BILLING_E_TRANS
WHERE (((UBILL_CURRENT_BILLING_E_TRANS.COMPLEX_NUMBER)=
[PCust]));

I've also tried to change the PCust to a text , but that
didn't sem to help either.
This problem has something to do with the fact that the
fist 2 parms are fields, while the 3rd parm is criteria.

Thanks.
 
On Fri, 21 Nov 2003 11:02:18 -0800,


The code I normally use for parameters is

Dim prm As Parameter
Dim qd As DAO.Querydef
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.Querydefs("yourqueryname")
For Each prm In qd.Parameters
qd.Value = Eval(qd.Name)
Nest Prm
Set rs = qd.OpenRecordset


I haven't seen the syntax you're using - I'm sure it can be tweaked to
work but can't immediately see how!
 
For Each prm In qd.Parameters
qd.Value = Eval(qd.Name)
Nest Prm

You've clearly typed this in rather than C&P -- should the middle line be

prm.Value = Eval(prm.Name)

B Wishes


Tim F
 
Hi,
You've posted to a DAO group but you're using ADO.
Hence some confusion in the replies.
Are using Jet or SQL Server?
If SQL Server, you must specify the size of any string parameters.

The error is telling you you haven't supplied enough info.
Set parameter = command.CreateParameter (Name, Type, Direction, Size, Value)
 
Back
Top