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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

additem fine but addlistitem giving function, argument count errors 2

Status
Not open for further replies.

ahaws

Programmer
Nov 28, 2001
355
US
hello all-
getting pretty frustrated here! I have 2 fields from Keydesc that I want to add to this moverlist. I want the Description(Desc) and Primary to show. I've taken a look at MikeLewis response to another question about additem, and I have tried the using the code below...



LOCAL nRow
This.ColumnCount = 2
This.ColumnWidths = "75,60"

If !Used('keydesc')
Select 0
Use keydesc
Else
Select keydesc
Endif
Set Order To Desc
Go Top

nrow = 1
Scan
This.AddItem(Desc)
This.AddListItem(Primary,nrow,2)
Select keydesc
Skip
nrow = nrow + 1
Endscan
Thisform.Refresh()

I keep getting a function, argument, or type is invalid for this line:
[red]
This.AddListItem(Primary,nrow,2)
[/red]
I am doing it the exact way, and I am confused as why it is giving me the errors...
any takers?

Thanks in Advance-
angie
 
Hi

Try..

WITH thisform.combo1
.addlistitem(Desc, 1, 1)
.listitem(1,2) = "Primary"
.addlistitem(Desc, 2, 1)
.listitem(2,2) = "Primary"
.addlistitem(Desc, nRow, 1)
.listitem(nRow,2) = "Primary"
ENDWITH

OR

WITH thisform.combo1
nRow = 0
SCAN
nRow = nRow+1
.addlistitem(Desc, nRow, 1)
.listitem(nRow,2) = "Primary"
ENDSCAN
ENDWITH



____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Angie,

There are two possible problems here. First, I think there is a problem with your SKIP command.

In a SCAN/ENDSCAN loop, you don't want to include a SKIP. The SCAN skips the records automatically. So, each time round the loop, you are skipping twice, and the record pointer will get out of sync with the index (nRow). Try taking out the SKIP.

The other point is: What exactly is Primary. Is it a field in the table? If so, that should be OK. If it is a variable, have you made sure that the variable has been defined?

If neither of these suggestions help, come back and I will try to reproduce the problem.

MIke


Mike Lewis
Edinburgh, Scotland
 
Hi All-
Hope everyone had a good holiday. I will try both Ramani's and Mike's suggestion, and get back to the post. thanks for your help.
Angie
 
Hi Angie,

Here is a sample that may assist you too.

faq184-4322 Programmatically Loading & Referencing Listbox Items

Jim Osieczonek
Delta Business Group, LLC
 
Hi Ramani-
I have tried your suggestion, however, I cannot get the 2nd column source to show....if I include the "" when I try:

WITH thisform.combo1
nRow = 0
SCAN
nRow = nRow+1
.addlistitem(Desc, nRow, 1)
.listitem(nRow,2) = "Primary"
ENDSCAN
ENDWITH

I get the desc field in the 1st column, but all rows say "Primary" for the second. It is not liking the parenthesis I guess...

Im not quite sure what to do next...everything I try throws an error.

Thanks
Angie
 
Hey again-
I think I figured out why I couldnt get past an error...the "Primary" field is numeric, so I had to STR() the field before I could put in the list...wasn't sure until I tried to add without the parenthesis and it told me it was a data type mismatch...so here's what I did and it worked. Thanks Ramani- and thanks to all that responded:

With Thisform.moverlists1.lstSource
.ColumnWidths = "100,20"
.ColumnCount = 2
nRow = 0
Scan
If !Empty(keydesc.Desc)
nRow = nRow + 1
.AddListItem(Desc,nRow,1)
.ListItem(nRow,2) = STR(keydesc.primary,3)
Endif
Endscan
Endwith

Angie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top