PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Last Value in a Table - Basic Question !
Last Value in a Table - Basic Question !
Débuté par Denis Vaughan, 19 aoû. 2008 21:49 - 9 réponses
Posté le 19 août 2008 - 21:49
Hi, I am trying to get the value of a column from the last record in a table.

I have tried to use HLast, HSeekLast but can't seem to get the value.
I also tried to create a Select Query giving me the MAX of the column in question (it is an incrementing number). This works in Query Test, but when I try to update a variable it only gives the value 1 which I assume is a true/false type value.

Can anyone advise - new to WINDEV.

DV
Posté le 20 août 2008 - 17:55
When you refer to a 'Table' are you referring to a Table Control? or are you referring to a Data file in the database?

To access the last record in a table control assuming you have a table called TABLE1 and columns called Name, Address etc

you can try something like :

sName is string
sName = Table1.Name[Table1..occurrence]

the above code will return the Name column value from the last row of the table and assign it to the sName variable.

If you are looking for the last record in a data file then you can use the HREADLAST command.

Hope this helps.

Gautam
Posté le 20 août 2008 - 18:21
Hi Gautam

Thank you for your response.

I am trying to read the last value from a data file. I have used HREADLAST but it is not giving me the value I expect.

The data file as 28 rows and the last row has an ID of 28. I have the following code against a button control and to test I was showing the returned value in an edit box:

gnMatchTableNextId=HLast(matched,MatchID)
EDT_LastMatch=gnMatchTableNextId

The value it returns is always 1

The data file is a table in MS Access

Thanks

Denis
Posté le 20 août 2008 - 19:05
check if that field is defined as a key and start the
"hlitrechecherserrnier" (sorry for french) using this key.

--
Michel HERRSCHER Consultant
tel : +33450870912

"Denis Vaughan" <denis.vaughan@pocasystems.ie> a écrit dans le message de
news: 261f8e9824711b88e158f1c52b9fd424@news.pcsoft...

Hi Gautam

Thank you for your response.

I am trying to read the last value from a data file. I have used HREADLAST
but it is not giving me the value I expect.

The data file as 28 rows and the last row has an ID of 28. I have the
following code against a button control and to test I was showing the
returned value in an edit box:

gnMatchTableNextId=HLast(matched,MatchID)
EDT_LastMatch=gnMatchTableNextId

The value it returns is always 1

The data file is a table in MS Access

Thanks

Denis
Posté le 20 août 2008 - 19:37
Hi, MatchID is defined as Key.

Thanks

DV
Posté le 21 août 2008 - 11:21
well ,

so can we see your code?


--
Michel HERRSCHER Consultant
tel : +33450870912

"Denis Vaughan" <denis.vaughan@pocasystems.ie> a écrit dans le message de
news: 3777411c6735e7ea70cc380a91e09061@news.pcsoft...

Hi, MatchID is defined as Key.

Thanks

DV
Posté le 21 août 2008 - 12:35
Hi,

I am using the following:

gnMatchTableNextID=HReadLast(matched,MatchID)
EDT_LastMatch=gnMatchTableNextID

Thanks

DV
Posté le 22 août 2008 - 09:48
Hi Denis,

The return value of the HReadLast function is a Boolean, describing whether
a record was successfully read or not.

Assuming "matched" is your file name (table), and MatchID the column you are
searching on, what you need is:

HReadLast(matched,MatchID)
EDT_LastMatch = matched.MatchID


Cheers...
Roger

"Denis Vaughan" <denis.vaughan@pocasystems.ie> wrote in message
news:0008338a348d928a62785d277a9bea35@news.pcsoft...

Hi,

I am using the following:

gnMatchTableNextID=HReadLast(matched,MatchID)
EDT_LastMatch=gnMatchTableNextID

Thanks

DV
Posté le 22 août 2008 - 11:37
CQFD ( french acronym) ... Roger has got it.

(Same response from me)

--
Michel HERRSCHER Consultant
tel : +33450870912

"Roger Dunk" <roger@at.com.au> a écrit dans le message de news:
48adec86@news.pcsoft.fr...



Hi Denis,

The return value of the HReadLast function is a Boolean, describing
whether
a record was successfully read or not.

Assuming "matched" is your file name (table), and MatchID the column you
are
searching on, what you need is:

HReadLast(matched,MatchID)
EDT_LastMatch = matched.MatchID


Cheers...
Roger

"Denis Vaughan" <denis.vaughan@pocasystems.ie> wrote in message
news:0008338a348d928a62785d277a9bea35@news.pcsoft...

Hi,

I am using the following:

gnMatchTableNextID=HReadLast(matched,MatchID)
EDT_LastMatch=gnMatchTableNextID

Thanks

DV
Posté le 22 août 2008 - 12:57
Richard / Michel,

That's brilliant thanks. I know all very basic but it's a big help, worked perfect.

Regards

Denis