Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lookup prior to Update - submit?

Status
Not open for further replies.

puterdude

Technical User
Apr 13, 2001
51
US
Hi,

I have a form with 15 fields on it. They are validated with javascript for numeric values only which is okay. I would like to be able to check the values against a table to make sure they are valid prior to them being accepted.
The record is already created in a previous screen, with these 15 fields blank. I am showing only parts of the record at any one time to keep it less confusing. So, I create a record with a key and then allow the user to fill in the 15 fields. I just want to make sure they enter values that are legitimate, based on what is in another table. Is this possible? Any suggestions appreciated.

Thanks,

Puterdude
 
Hi,

It sounds like all you have to do is do your validation just before you ipnut the new items into the table. If there is an error th you can return the form for the corrections.

Mark
 
Mark,
Yes, that is what I would like to do, including highlighting the incorrect entry(s) so they can fix them. The question is how? I haven't a clue. Javascript? ASP?
I'm new at ASP and if you hit submit, wont it automatically update the record? How can you intervene with a table lookup prior to posting the record?

And dumb it down for me, doc. None of your medical mumbo-jumbo.

puterdude
 
You can do this with either ASP or JavaScript. Since you know what the valid values are before sending this page to the browser, you could create arrays of data that contain these valid values. After checking to see if the user input a number, you could then check to see if this number is valid against the array of valid values. This is efficient, as no round trips to the server are required until all the values are acceptable. Nice for the user, no waiting to download the web page over and over. Nice for the server as there is less demands placed on it.

A second solution is to check this on the ASP side when the user clicks the submit button. You would create a recordset or array of valid values from the database table and check these against the values entered by the user. If they are valid, go ahead and update your record. If not, redisplay the form with the user's values already inserted in the 15 text boxes. You could then place a red text message next to any value that isn't valid.

Hope this helps.
 
GabeC
Sounds good either way. Can you point me to an example of how to load the array from the table? There are 12000 values, is that a problem?

Thanks,

Puterdude
 
From the MSDN January 2001 edition:


GetRows Method
Retrieves multiple records of a Recordset object into an array.

Syntax
array = recordset.GetRows( Rows, Start, Fields )
Return Value
Returns a Variant whose value is a two-dimensional array.

Parameters
Rows
Optional. A GetRowsOptionEnum value that indicates the number of records to retrieve. The default is adGetRowsRest.
Start
Optional. A String value or Variant that evaluates to the bookmark for the record from which the GetRows operation should begin. You can also use a BookmarkEnum value.
Fields
Optional. A Variant that represents a single field name or ordinal position, or an array of field names or ordinal position numbers. ADO returns only the data in these fields.
Remarks
Use the GetRows method to copy records from a Recordset into a two-dimensional array. The first subscript identifies the field and the second identifies the record number. The array variable is automatically dimensioned to the correct size when the GetRows method returns the data.

If you do not specify a value for the Rows argument, the GetRows method automatically retrieves all the records in the Recordset object. If you request more records than are available, GetRows returns only the number of available records.

If the Recordset object supports bookmarks, you can specify at which record the GetRows method should begin retrieving data by passing the value of that record's Bookmark property in the Start argument.

If you want to restrict the fields that the GetRows call returns, you can pass either a single field name/number or an array of field names/numbers in the Fields argument.

After you call GetRows, the next unread record becomes the current record, or the EOF property is set to True if there are no more records.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top