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
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
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]
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]
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
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
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
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
> 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
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