Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Operator/operand type mismatch

Status
Not open for further replies.

EKC

Technical User
Jan 13, 2001
43
CA
Hi,
I'm getting this message when I try to compare value in the Cell with a value of the field in the cursor c_report.ordate (bolded line in code):

SELECT c_report
For i=7 to _TALLY

.Cells(i,1)=c_report.cust
.Cells(i,2)=c_report.orderID
.Cells(i,3)=c_report.orline
.Cells(i,4)=c_report.part
.Cells(i,5)=c_report.clas
.Cells(i,6)=c_report.group

For k=10 to 20 step 2
if (.Cells(5,k).Value)=(c_report.ordate) then

.Cells(i,k)=c_report.ordate
.Cells(i,k+1)=c_report.QTY
Else
.Cells(i,10)=c_report.ordate
.Cells(i,11)=c_report.QTY
Endif
EndFor
GOTO i
EndFor


Cells(k,10)(k=5 to 20 step2) already contains dates in I set earlier as those dates are part of heading and they are in format month/day/year (4/11/01) the same as c_report.ordate field.
My program should display all records in Excel sheet so from my program I' opening excel:

XL=CreateObject("Excel.Application")
XL.Visible=.T.
XL.Workbooks.Add()

Thanks for any help,
Lyn


 
Did you try:
if not isnull(.Cells(5,k).Value)
if (.Cells(5,k).Value)=(c_report.ordate) then
.....stuff
endif
endif
 
Let me make this problem more clear:in this line of code

if (.Cells(5,k).Value)=(c_report.ordate) then

.Cells(5,k) always contain dates(it's never null) but dates is in format 4/11/01 12:00:00(although showing only 4/11/01 in cells).Ordate is date..
Strangely ,when I put this line
If back_report.ordate={^2001/4/11} it works but I need those cell values to compare with.I think it need to be converted somehow.
Thanks
lyn
 
You can probably use
IF TYPE(.Cells(5,k).Value) = "D"
if (.Cells(5,k).Value)=(c_report.ordate) then

.Cells(i,k)=c_report.ordate
.Cells(i,k+1)=c_report.QTY
else
.Cells(i,10)=c_report.ordate
.Cells(i,11)=c_report.QTY
endif
Else
.Cells(i,10)=c_report.ordate
.Cells(i,11)=c_report.QTY
ENDIF
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
I don't know if this has any bearing, but also keep in mind that your date setting under your tools->options->general is consistent with what you're trying to achieve.
 
Let me ask another question: when I explicitly set
.Cells(5,k).Value={^2001/4/11} code works so my question is how to convert value contained in .Cells(5,k) to be in form {^yyyy/mm/dd}.Is it some of the date function I need to use and what is ^ in this expression.When I get message "Operator mismatch" it's like program try to compere different data types!

Any idea appreciated,
Lyn
 
Have you SET CENTURY ON ? ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
I set this
SET CENTURY ON
SET DATE TO AMERICAN
 
In the excel, have you set the default date formats ?. If not, you make have to set that probably.? I am not sure.. but just a quick reflex thinking... may be you can try this :) ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Hi Lyn,

If you are receiving a "Operator/operand type mismatch" error, it's because you ARE comparing different data types.

You probably have the cell formatted as text in Excel. Try:

? VARTYPE(.Cells(5,k).Value)

If it returns C, then that is the case. You'll have to convert it to a date type using something like:

ldNewDate=CTOD(.Cells(5,k).Value)
IF ldNewDate=c_report.ordate
WAIT WINDOW "Lyn Got His/Her Groove Back!"
ENDIF Jon Hawkins

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
If your value is actually "4/11/01 12:00:00", then it is a DATETIME type, not a DATE type. Yes, you can write either one to a field and it will adjust itself, but you cannot compare them. Try using the TTOD() function to convert a DATETIME value to a DATE:

if ttod(.Cells(5,k).Value)=(c_report.ordate) then

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top