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!

inserting a request.form but changing the value of a field first 1

Status
Not open for further replies.

timtom

Programmer
Jul 12, 2001
78
GB
Sorry, subject line wasn't descriptive. But, hey, I'm stuck. I'm inserting the results of a few fields from a form like this.

<%option explicit
dim objCn, objRs, sSql
%>
<!-- #include file = &quot;../includes/db.asp&quot; -->
<%
dim person_name, requests, time_to_contact
dim original_notes, leader, cor_blimey
dim user
dim the_day_today

person_name = request.form(&quot;person&quot;)
requests = request.form(&quot;selectRequest&quot;)
time_to_contact = request.form(&quot;txttime&quot;)
original_notes = request.form(&quot;txtnotes&quot;)
leader = request.form(&quot;leader&quot;)
cor_blimey = request.form(&quot;txtCorradd&quot;)
user = session(&quot;USERID&quot;)
the_day_today = FormatDateTime(Date, 2)

if session(&quot;USERID&quot;) <> &quot;&quot; then
sSql = &quot;INSERT INTO SFINANCE (PERSON_QR, DATE_OF_REF, REQUEST, CONTACT_TIME, ORIG_NOTES, LEAD_GENERATED, ACC_MAN, CORR_ADDRESS) VALUES ( '&quot; &_person_name & &quot;', '&quot; & the_day_today & &quot;', '&quot; & requests & &quot;', '&quot; & time_to_contact & &quot;', '&quot; & original_notes & &quot;', '&quot; & leader & &quot;', '&quot; & user & &quot;','&quot; & cor_blimey & &quot;')&quot;

set objRs = objCn.execute (sSql)
call closeConnection(objCn)
end if
response.redirect &quot;view.asp&quot;
%>
(that's the whole of the page - and it works fine like that)

Anyway, my question is. I don't want to insert the ACTUAL value of the 'person' text field. Instead I want to use that value in a query that I want to run on this page in order to get the real value (a sku/qr from another table) that I want to insert. How do I do that, structure-wise? Where do I put the query? I'm pretty baffled and would love some help. Promise to send happy thoughts to anyone gracious enough to lend a hand. Thankyou kindlymuch.

Sarah :)
 
Before doing your insert query, take the person_name and use it in a query to retrieve the qr(whatever that is).
Process flow would be:
Code:
- Get all request parameters
- Open Connection
- Query for person_qr
- Insert Record
- Close Connection
Wushutwist
 
Thanks Wushutwist. I'm still trying, but I've got your authoritative list stuck in my brain and copied into notepad. I am sticking to the order in the said list and I'm sure I'll get it soon. Cheers x
 
Hi, if I get your point OK then :

pSQL = &quot;SELECT qr from PersonTable where PersonName='&quot;
& Person_Name & &quot;'&quot;
set personRS= objCn.execute (pSql)
Person_QR = pSQL(&quot;qr&quot;)
personRS.close
Set personRS=Nothing

.....

if session(&quot;USERID&quot;) <> &quot;&quot; then
sSql = &quot;INSERT INTO SFINANCE (PERSON_QR, DATE_OF_REF, REQUEST, CONTACT_TIME, ORIG_NOTES, LEAD_GENERATED, ACC_MAN, CORR_ADDRESS) VALUES ( '&quot; & Person_QR & &quot;', '&quot; & the_day_today & &quot;', '&quot; & requests & &quot;', '&quot; & time_to_contact & &quot;', '&quot; & original_notes & &quot;', '&quot; & leader & &quot;', '&quot; & user & &quot;','&quot; & cor_blimey & &quot;')&quot;


Hope this is what you're looking for

Good Luck

François
 
François, I love you. It works and it works brill. You have saved me possibly three days of staring at 500 error messages before I would have ultimately and inevitably given up.

Cheers

Sarah :^)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top