473,396 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Extract final field in row which has a value - an array issue perhaps?

Access 2000

I need some help interogatting a table and extracting via ASP the final
field in a row which has a value. In other words, I have a maximum of 10
fields but, at the user level he may he only enter values into the first
four. I need to ALWAYS extract the final or last field that has a value. In
the example below this would be PriceField5 which has a value of $162,000.

The user stopped at this field and left the rest blank.

I considered cycling through the row and checking for null or empty values
but I suspect this may be very messy and have not had much success in the
past. Is there a better more elegant way to achieve my goal?

--PRICE TABLE--
PriceField1 (eg 100,000)
PriceField2 (eg 130,000)
PriceField3 (eg 142,000)
PriceField4 (eg 152,000)
PriceField5 (eg 162,000)
PriceField6 (empty)
PriceField7 (empty)
PriceField8 (empty)
PriceField9 (empty)
PriceField10 (empty)

Many thanks in advance

Jason



Jul 19 '05 #1
9 1936
I would think that looping would be okay for this. What are you trying to
do or why haven't you had luck with that?

Ray at work
"jason" <ja***@catamaranco.com> wrote in message
news:uF**************@tk2msftngp13.phx.gbl...
Access 2000

I need some help interogatting a table and extracting via ASP the final
field in a row which has a value. In other words, I have a maximum of 10
fields but, at the user level he may he only enter values into the first
four. I need to ALWAYS extract the final or last field that has a value. In the example below this would be PriceField5 which has a value of $162,000.

The user stopped at this field and left the rest blank.

I considered cycling through the row and checking for null or empty values but I suspect this may be very messy and have not had much success in the
past. Is there a better more elegant way to achieve my goal?

--PRICE TABLE--
PriceField1 (eg 100,000)
PriceField2 (eg 130,000)
PriceField3 (eg 142,000)
PriceField4 (eg 152,000)
PriceField5 (eg 162,000)
PriceField6 (empty)
PriceField7 (empty)
PriceField8 (empty)
PriceField9 (empty)
PriceField10 (empty)

Many thanks in advance

Jason


Jul 19 '05 #2
Well in the past I would try checking for null values and empty values eg
len(request.form.item("PriceField1"). But, I usually end up with longwinded
code. I thought perhaps there might be away to put the entire 10 fields into
an array and they cycle through them.......when you say loop through them I
am not even sure which convention to use or

rs.getrows ?
Do until rs.eof?

I am also not sure whether I should cycle all the form elements: eg:
request.form.item(i) or just do them individually?

At the risk of sounding lazy could you possibly submit an example of how you
would do it?

Many thanks
Jason
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:#F*************@TK2MSFTNGP10.phx.gbl...
I would think that looping would be okay for this. What are you trying to
do or why haven't you had luck with that?

Ray at work
"jason" <ja***@catamaranco.com> wrote in message
news:uF**************@tk2msftngp13.phx.gbl...
Access 2000

I need some help interogatting a table and extracting via ASP the final
field in a row which has a value. In other words, I have a maximum of 10
fields but, at the user level he may he only enter values into the first
four. I need to ALWAYS extract the final or last field that has a value.

In
the example below this would be PriceField5 which has a value of $162,000.
The user stopped at this field and left the rest blank.

I considered cycling through the row and checking for null or empty

values
but I suspect this may be very messy and have not had much success in the past. Is there a better more elegant way to achieve my goal?

--PRICE TABLE--
PriceField1 (eg 100,000)
PriceField2 (eg 130,000)
PriceField3 (eg 142,000)
PriceField4 (eg 152,000)
PriceField5 (eg 162,000)
PriceField6 (empty)
PriceField7 (empty)
PriceField8 (empty)
PriceField9 (empty)
PriceField10 (empty)

Many thanks in advance

Jason



Jul 19 '05 #3
Wait, are you talking about a recordset here or a form collection?

If form collection, there is no first and last. (Some would say the same
about columns in a database table as well, but that's all in how you
interpret things.)

Ray at work

"jason" <ja***@catamaranco.com> wrote in message
news:uD**************@TK2MSFTNGP10.phx.gbl...
Well in the past I would try checking for null values and empty values eg
len(request.form.item("PriceField1"). But, I usually end up with longwinded code. I thought perhaps there might be away to put the entire 10 fields into an array and they cycle through them.......when you say loop through them I am not even sure which convention to use or

rs.getrows ?
Do until rs.eof?

I am also not sure whether I should cycle all the form elements: eg:
request.form.item(i) or just do them individually?

At the risk of sounding lazy could you possibly submit an example of how you would do it?

Many thanks
Jason
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:#F*************@TK2MSFTNGP10.phx.gbl...
I would think that looping would be okay for this. What are you trying to
do or why haven't you had luck with that?

Ray at work
"jason" <ja***@catamaranco.com> wrote in message
news:uF**************@tk2msftngp13.phx.gbl...
Access 2000

I need some help interogatting a table and extracting via ASP the final field in a row which has a value. In other words, I have a maximum of 10 fields but, at the user level he may he only enter values into the first four. I need to ALWAYS extract the final or last field that has a
value. In
the example below this would be PriceField5 which has a value of

$162,000.
The user stopped at this field and left the rest blank.

I considered cycling through the row and checking for null or empty

values
but I suspect this may be very messy and have not had much success in the past. Is there a better more elegant way to achieve my goal?

--PRICE TABLE--
PriceField1 (eg 100,000)
PriceField2 (eg 130,000)
PriceField3 (eg 142,000)
PriceField4 (eg 152,000)
PriceField5 (eg 162,000)
PriceField6 (empty)
PriceField7 (empty)
PriceField8 (empty)
PriceField9 (empty)
PriceField10 (empty)

Many thanks in advance

Jason




Jul 19 '05 #4
> If form collection, there is no first and last.

That depends. You can certainly iterate through a form collection in the
same order as the form elements appeared on the page (see
http://www.aspfaq.com/2036). I don't believe this will obey optioanl
TABINDEX settings, however.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #5
I'm sorry - I would be iterating the form collection on the collecting page.

But, my main problem is initially interoggating the row or record to find
the last non-empty field in a row containng a maximu of 10 fields.

Thus, fields 1-5 might containt data (ie price).

I would need to determine that field five has data and then display the
first five field values in INPUT boxes for the user to edit and then submit
to the next page.

This is the challenge for me...I am not exactly sure how to do this.

Does this make sense?

Thanks
Jason
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:#F*************@TK2MSFTNGP10.phx.gbl...
I would think that looping would be okay for this. What are you trying to
do or why haven't you had luck with that?

Ray at work
"jason" <ja***@catamaranco.com> wrote in message
news:uF**************@tk2msftngp13.phx.gbl...
Access 2000

I need some help interogatting a table and extracting via ASP the final
field in a row which has a value. In other words, I have a maximum of 10
fields but, at the user level he may he only enter values into the first
four. I need to ALWAYS extract the final or last field that has a value.

In
the example below this would be PriceField5 which has a value of $162,000.
The user stopped at this field and left the rest blank.

I considered cycling through the row and checking for null or empty

values
but I suspect this may be very messy and have not had much success in the past. Is there a better more elegant way to achieve my goal?

--PRICE TABLE--
PriceField1 (eg 100,000)
PriceField2 (eg 130,000)
PriceField3 (eg 142,000)
PriceField4 (eg 152,000)
PriceField5 (eg 162,000)
PriceField6 (empty)
PriceField7 (empty)
PriceField8 (empty)
PriceField9 (empty)
PriceField10 (empty)

Many thanks in advance

Jason



Jul 19 '05 #6

"jason" <ja***@catamaranco.com> wrote in message
news:el**************@TK2MSFTNGP10.phx.gbl...
I'm sorry - I would be iterating the form collection on the collecting page.
But, my main problem is initially interoggating the row or record to find
the last non-empty field in a row containng a maximu of 10 fields.

Thus, fields 1-5 might containt data (ie price).

I would need to determine that field five has data and then display the
first five field values in INPUT boxes for the user to edit and then submit to the next page.

This is the challenge for me...I am not exactly sure how to do this.

Does this make sense?

Using what Aaron posted, you can do:

Dim i
For i = Request.Form.Count To 1 Step -1
If Request.Form.Item(i) <> "" Then
Response.Write "The last item with data is " & Request.Form.Key(i)
Exit For
End If
Next

That should get you started, anyway. That will loop through the form
collection backwards and look for the ~first~ value, which will be the last,
since it's going in reverse. Note it doesn't trim values or discriminate
form field names or anything.

Ray at work
Jul 19 '05 #7
Thank you - I did not know you could actually go in reverse.....I will take
a closer look at the aspfaq and build furhter from it...

Cheers
Jason
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:#E**************@TK2MSFTNGP12.phx.gbl...

"jason" <ja***@catamaranco.com> wrote in message
news:el**************@TK2MSFTNGP10.phx.gbl...
I'm sorry - I would be iterating the form collection on the collecting page.

But, my main problem is initially interoggating the row or record to find the last non-empty field in a row containng a maximu of 10 fields.

Thus, fields 1-5 might containt data (ie price).

I would need to determine that field five has data and then display the
first five field values in INPUT boxes for the user to edit and then

submit
to the next page.

This is the challenge for me...I am not exactly sure how to do this.

Does this make sense?

Using what Aaron posted, you can do:

Dim i
For i = Request.Form.Count To 1 Step -1
If Request.Form.Item(i) <> "" Then
Response.Write "The last item with data is " & Request.Form.Key(i)
Exit For
End If
Next

That should get you started, anyway. That will loop through the form
collection backwards and look for the ~first~ value, which will be the

last, since it's going in reverse. Note it doesn't trim values or discriminate
form field names or anything.

Ray at work

Jul 19 '05 #8
ps: This reverse form script works absolutely great....I can find so many
applications for it...thanks again to Ray and Aaron.

- Jason
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:#E**************@TK2MSFTNGP12.phx.gbl...

"jason" <ja***@catamaranco.com> wrote in message
news:el**************@TK2MSFTNGP10.phx.gbl...
I'm sorry - I would be iterating the form collection on the collecting page.

But, my main problem is initially interoggating the row or record to find the last non-empty field in a row containng a maximu of 10 fields.

Thus, fields 1-5 might containt data (ie price).

I would need to determine that field five has data and then display the
first five field values in INPUT boxes for the user to edit and then

submit
to the next page.

This is the challenge for me...I am not exactly sure how to do this.

Does this make sense?

Using what Aaron posted, you can do:

Dim i
For i = Request.Form.Count To 1 Step -1
If Request.Form.Item(i) <> "" Then
Response.Write "The last item with data is " & Request.Form.Key(i)
Exit For
End If
Next

That should get you started, anyway. That will loop through the form
collection backwards and look for the ~first~ value, which will be the

last, since it's going in reverse. Note it doesn't trim values or discriminate
form field names or anything.

Ray at work

Jul 19 '05 #9
You're welcome!

Ray at work

"jason" <ja***@catamaranco.com> wrote in message
news:O%****************@TK2MSFTNGP12.phx.gbl...
ps: This reverse form script works absolutely great....I can find so many
applications for it...thanks again to Ray and Aaron.

- Jason
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:#E**************@TK2MSFTNGP12.phx.gbl...

"jason" <ja***@catamaranco.com> wrote in message

Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: pablo | last post by:
Dear News Groupers, I'am trying to send a php array with a hidden input field from a form to another script. The array is NOT made directly by way of <input name="arrayname" />. The array is...
6
by: charlie_M | last post by:
I figured out via various help from this forum... EXAMPLE: onClick="document.forms.MYBUTTON.value='SIMPLE';document.forms.submit()" In my CGI I see "MYBUTTON" = "SIMPLE" and this works...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
6
by: Rene | last post by:
Could anyone tell me what is the reason I can't initialize the members of a struct like this: public struct SomeStruct { public int uno = 1; // Error public int dos = 2; // Error public...
3
by: zek2005 | last post by:
Hi friends! I have a varchar field in my DB with numeric values separates by spaces. I need to extract the numbers to create an array. Example 1: 1820 1823 1825 --> need to be transform into ...
7
by: fox | last post by:
Hi, Lacking javascript knowledge, I just realized why my project has a bug. I am using ASP to loop through a set of records while it creates URLs with a querystring that has a single value pair....
7
by: Mark | last post by:
let's say i have a table in my database, with only one column. all i want to do is retrieve a list of the entries.. i could do it like this $result = mysql_query("SELECT * FROM t1"); while( $x =...
3
by: Stan McCann | last post by:
I've searched and searched for a function to create an array from a string maintaining key/value pairs and keep coming up blank. This seems to me that it would be quite commonly used. What I am...
3
by: no1zson | last post by:
I have been working on this application for weeks now, it is almost finished, but I am getting errors that I am unable to work through. Can someone look at my code and see if anything stands out...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.