Index
2005-01-25 17:20PLBorkholder : ListBox and Recno()
2005-01-25 19:44Stephen the Cook : RE: ListBox and Recno()
2005-01-25 22:04Richard Kaye : Re: ListBox and Recno()
2005-01-26 00:35Chet Gardiner : Re: ListBox and Recno()
2005-01-26 07:24Charlie Coleman : RE: ListBox and Recno()
2005-01-26 08:59Stephen the Cook : RE: ListBox and Recno()
2005-01-26 09:28Stuart Dunkeld : Re: ListBox and Recno()
2005-01-26 09:44Stephen the Cook : RE: ListBox and Recno()
2005-01-26 10:02Stuart Dunkeld : Re: ListBox and Recno()
2005-01-26 10:42PLBorkholder : Re: ListBox and Recno()
Back to top
ListBox and Recno()

Author: PLBorkholder

Posted: 2005-01-25 17:20:03   Link

Does anyone know how to incorporate the recno() into a list box from the

alias that it is pulling from?

I need to have the RowsourceType = 2 Alias

I have in the Rowsource:

certhdr.vcfurno1,loadno1,customer,partno,ponum,htdate,swonum,tokenno

I tried adding the Recno() at the end but it errors out:

certhdr.vcfurno1,loadno1,customer,partno,ponum,htdate,swonum,tokenno,recno('certhdr')

I keep getting the error "Not a character expression"

PB

©2005 PLBorkholder
Back to top
RE: ListBox and Recno()

Author: Stephen the Cook

Posted: 2005-01-25 19:44:52   Link

PLBorkholder wrote:

> Does anyone know how to incorporate the recno() into a list box from

> the

> alias that it is pulling from?

> I need to have the RowsourceType = 2 Alias

>

> I have in the Rowsource:

> certhdr.vcfurno1,loadno1,customer,partno,ponum,htdate,swonum,tokenno

>

> I tried adding the Recno() at the end but it errors out:

>

certhdr.vcfurno1,loadno1,customer,partno,ponum,htdate,swonum,tokenno,recno('

certhdr')

Why not a P-key to the primary table?

Stephen Russell

S.R. & Associates

Memphis, TN 38115

901.246-0159

©2005 Stephen the Cook
Back to top
Re: ListBox and Recno()

Author: Richard Kaye

Posted: 2005-01-25 22:04:57   Link

Possibly you need to wrap the recno() inside str() or transform()?

PLBorkholder wrote:

> Does anyone know how to incorporate the recno() into a list box from

> the alias that it is pulling from?

> I need to have the RowsourceType = 2 Alias

>

> I have in the Rowsource:

> certhdr.vcfurno1,loadno1,customer,partno,ponum,htdate,swonum,tokenno

>

> I tried adding the Recno() at the end but it errors out:

> certhdr.vcfurno1,loadno1,customer,partno,ponum,htdate,swonum,tokenno,recno('certhdr')

>

>

> I keep getting the error "Not a character expression"

>

> PB

>

>

[excessive quoting removed by server]

©2005 Richard Kaye
Back to top
Re: ListBox and Recno()

Author: Chet Gardiner

Posted: 2005-01-26 00:35:44   Link

A trick I use a lot is to create an extra field called recno and fill it

with the record number. Can you do that?

Richard Kaye wrote:

> Possibly you need to wrap the recno() inside str() or transform()?

>

> PLBorkholder wrote:

>

>> Does anyone know how to incorporate the recno() into a list box from

>> the alias that it is pulling from?

>> I need to have the RowsourceType = 2 Alias

>>

>> I have in the Rowsource:

>> certhdr.vcfurno1,loadno1,customer,partno,ponum,htdate,swonum,tokenno

>>

>> I tried adding the Recno() at the end but it errors out:

>> certhdr.vcfurno1,loadno1,customer,partno,ponum,htdate,swonum,tokenno,recno('certhdr')

>>

>>

>> I keep getting the error "Not a character expression"

>>

>> PB

>>

>>

[excessive quoting removed by server]

©2005 Chet Gardiner
Back to top
RE: ListBox and Recno()

Author: Charlie Coleman

Posted: 2005-01-26 07:24:28   Link

At 06:44 PM 1/25/2005 -0600, you wrote:

> > Does anyone know how to incorporate the recno() into a list box from the

> > alias that it is pulling from?

> > I need to have the RowsourceType = 2 Alias

> >

> > I have in the Rowsource:

> > certhdr.vcfurno1,loadno1,customer,partno,ponum,htdate,swonum,tokenno

...

If you are locked into using 'Alias' as the .rowsource then I'm not sure.

However, if you change the .rowsource to array you could put the record

number in the array. You could create a subclass of the listbox and give it

an array property.

E.g.

- create subclass of listbox

- add property .aItems[1,1]

- add method .getdata()

- subclass that class into special case - lstCertHdr

- of course, other properties of lstCertHdr could be set up - e.g.

ColumnCount, ColumnWidths, etc

For class lstCertHdr, put code like this in the .GetData() method:

*--- Method: GetData

SELECT vcfurno1, loadno1, customer, partno, ponum, htdate, swonum, recno() ;

FROM CERTHDR ;

INTO ARRAY THIS.aItems

THIS.requery() && I think needed to update listcount, etc

RETURN

The downside of this is you'd have to call the .GetData() method to refresh

the list. So if the data is rapidly changing and you're trying to get a

real-time view that data, this won't work very well IMO.

Hmmm... I was just wondering, if you've using ALIAS as the rowsource, and

if you have SET DELETED OFF (or you know there are no deleted records in

the source table/cursor), and if you are not sorting (and no index is used)

I think the ListIndex value would actually be the same as the recno value.

That's a lot of IFs, but it's something to consider if you're actually

locked into Alias, with real-time data changing....

Lastly, if you're into VFP 8 or later, you might want to consider a Grid.

There are a lot of new features starting in VFP 8 that can make a grid look

a lot like a listbox (better row highlighting behavior, etc).

HTH,

-Charlie

©2005 Charlie Coleman
Back to top
RE: ListBox and Recno()

Author: Stephen the Cook

Posted: 2005-01-26 08:59:54   Link

Chet Gardiner wrote:

> A trick I use a lot is to create an extra field called recno and fill

> it

> with the record number. Can you do that?

>

Doesn't anyone use something like ItemData or ItemIDData for retrieving

this?

In .NET you have this.ComboBox1.SelectedIndex to give you the item # in the

control your using.

Stephen Russell

S.R. & Associates

Memphis, TN 38115

901.246-0159

©2005 Stephen the Cook
Back to top
Re: ListBox and Recno()

Author: Stuart Dunkeld

Posted: 2005-01-26 09:28:34   Link

On Wed, 26 Jan 2005 07:59:54 -0600, Stephen the Cook

<stephen.russell@adribbers.com> wrote:

> Doesn't anyone use something like ItemData or ItemIDData for retrieving

> this?

>

> In .NET you have this.ComboBox1.SelectedIndex to give you the item # in the

> control your using.

I think the issue is to be able to tie the listbox rows back to the

underlying table, not specifically to know what row is selected in the

listbox.

Stuart

©2005 Stuart Dunkeld
Back to top
RE: ListBox and Recno()

Author: Stephen the Cook

Posted: 2005-01-26 09:44:10   Link

Stuart Dunkeld wrote:

> On Wed, 26 Jan 2005 07:59:54 -0600, Stephen the Cook

> <stephen.russell@adribbers.com> wrote:

>

>> Doesn't anyone use something like ItemData or ItemIDData for

>> retrieving this?

>>

>> In .NET you have this.ComboBox1.SelectedIndex to give you the item #

>> in the control your using.

>

> I think the issue is to be able to tie the listbox rows back to the

> underlying table, not specifically to know what row is selected in

> the listbox.

Isn't that what a P-Key is all about? Recno() is so wrong (IMO).

Especially if you have a joined table for your data source.

Stephen Russell

S.R. & Associates

Memphis, TN 38115

901.246-0159

©2005 Stephen the Cook
Back to top
Re: ListBox and Recno()

Author: Stuart Dunkeld

Posted: 2005-01-26 10:02:21   Link

> Isn't that what a P-Key is all about? Recno() is so wrong (IMO).

> Especially if you have a joined table for your data source.

I agree, but if you don't have a PK then recno is the next best thing:

legacy data often doesn't have PKs, especially if there is no

candidate for a PK in the data.

Stuart

©2005 Stuart Dunkeld
Back to top
Re: ListBox and Recno()

Author: PLBorkholder

Posted: 2005-01-26 10:42:46   Link

Thanks everyone for the creative responses.

(Sorry I had to leave the office soon after I sent my 1st email yesterday)

Yes, the biggest problem is that the existing structure does not have a

PK. :(

I tried to use the list box indices however because the screen allows

the user to click on the labels above each "column" to sort the data in

that order ascending/desc, the indices do not match the underlying record.

I thought about using a grid, however, I like the multi-select option on

the list box which allows me to perform functions on the group of records.

I could always switch it all to a grid with a check box to the far left

but I wanted to avoid the complexity of that .

I could also just issue an SQL - Select statement and pull in the record

number with that.

Philip

©2005 PLBorkholder