473,701 Members | 2,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1957
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***@catamara nco.com> wrote in message
news:uF******** ******@tk2msftn gp13.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.for m.item("PriceFi eld1"). 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.it em(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******** *****@TK2MSFTNG P10.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***@catamara nco.com> wrote in message
news:uF******** ******@tk2msftn gp13.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***@catamara nco.com> wrote in message
news:uD******** ******@TK2MSFTN GP10.phx.gbl...
Well in the past I would try checking for null values and empty values eg
len(request.for m.item("PriceFi eld1"). 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.it em(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******** *****@TK2MSFTNG P10.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***@catamara nco.com> wrote in message
news:uF******** ******@tk2msftn gp13.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******** *****@TK2MSFTNG P10.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***@catamara nco.com> wrote in message
news:uF******** ******@tk2msftn gp13.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***@catamara nco.com> wrote in message
news:el******** ******@TK2MSFTN GP10.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.Co unt To 1 Step -1
If Request.Form.It em(i) <> "" Then
Response.Write "The last item with data is " & Request.Form.Ke y(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******** ******@TK2MSFTN GP12.phx.gbl...

"jason" <ja***@catamara nco.com> wrote in message
news:el******** ******@TK2MSFTN GP10.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.Co unt To 1 Step -1
If Request.Form.It em(i) <> "" Then
Response.Write "The last item with data is " & Request.Form.Ke y(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******** ******@TK2MSFTN GP12.phx.gbl...

"jason" <ja***@catamara nco.com> wrote in message
news:el******** ******@TK2MSFTN GP10.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.Co unt To 1 Step -1
If Request.Form.It em(i) <> "" Then
Response.Write "The last item with data is " & Request.Form.Ke y(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***@catamara nco.com> wrote in message
news:O%******** ********@TK2MSF TNGP12.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******** ******@TK2MSFTN GP12.phx.gbl...

"jason" <ja***@catamara nco.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
25559
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 made by normal php code and then submitted between form-tags as echo "<input type='hidden' name=\"arrayname\" value=\"$arrayname\" />" ;
6
2747
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 fine.... except that the element MYBUTTON must exist as a hidden field.
193
9571
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 speak only of features in the spirit of C; something like object-orientation, though a nice feature, does not belong in C. Something like being able to #define a #define would be very handy, though, e.g: #define DECLARE_FOO(bar) #define...
6
21650
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 int tres = 3; // Error }
3
3518
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 1820 1823 1825
7
2534
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. This URL needs to open in a floating window if clicked. (this is for an administrator and so opening a small floater gives them more efficient access to the data that will be displayed). I now understand that because the ASP executes first, that...
7
6011
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 = mysql_fetch_row($result) ) { echo $x; } but it seems kinda silly to fetch an entire array, when only the first index is used. is there a better/more efficient way?
3
2820
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 doing is trying to pass an array using $_GET. To pass the array, it is rather simple to add it to my get string breaking the array into key,value,key,value,key,value. The problem is reading it back into an array. I've tried explode but that...
3
1746
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 that I might try correcting. First, I am getting Inventory2.java:187: actionPerformed(java.awt.event.ActionEvent) in cannot implement actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener; attempting to assign weaker access...
0
8736
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8649
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8977
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8934
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7824
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5904
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4410
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.