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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

From values after insert??

Status
Not open for further replies.

Cheech

Technical User
Nov 6, 2000
2,933
EU
Hey guys,

one of them that is doing my head in and will probably be so feckin obvious when i figure it out...
quick question after inserting a record from one page can you still use Request.Form("some_variable_name") to read in a value that was passed to the database? if not anyone solved this before??

Cheers A child of five would understand this. Send someone to fetch a child of five.
Groucho Marx (1895-1977)
 
Hey,
Not sure what you mean exactly, but do you mean can you still use Request.Form("variable_name") in another page after inserting? The best way to pass variables from multiple pages (as you might know) is using Session variables. You can define your Session variable by doing:

Session("variable_name") = Request.Form("variable_name")

And to answer your question exactly, I would have to say "yes" it is feasible cuz I've done it! Candie ;o)

"Mere distances between 2 people bring you all that much closer in the end!"
 
Yes I understand Session variables. Let me try to explain myself a little clearer..

The bit that works:--

I have a page "view.asp" that displays a number of records from a database selecting on date. Using the following logic:-

<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = Request.Form(&quot;Fdate&quot;)
if (Recordset1__MMColParam = &quot;&quot;) then Recordset1__MMColParam = Date()
%>

This allows the page which has a textfield called &quot;Fdate&quot; on it to submit to itself a new date and reload but if it is the first time visted then todays date is displayed as default.

The bit that doesn't work:--

I have an insert record page that puts new records into the database. There is a textfield on this page also called &quot;Fdate&quot;. After inserting the user is directed to &quot;view.asp&quot;.

What I want is, after inserting the record, for &quot;view.asp&quot; to display the date that has just been inserted, but it allways defaults to &quot;Date()&quot; so I can only figure the value of &quot;Fdate&quot; on the insert page is being lost or cleared because of being used in the database insert.

I just wondered if anyone can think what I am doing wrong or a way to overcome this?

Cheers Cheech A child of five would understand this. Send someone to fetch a child of five.
Groucho Marx (1895-1977)
 
I think I understand what you're saying but you just making me more confused! Can you try and explain a little more clearer? With you going from one page to the next and saying certain things about it here and there and which page is doing what, it's making it kind of hard... Candie ;o)

&quot;Mere distances between 2 people bring you all that much closer in the end!&quot;
 
Cheech,

Have you set up your database field for this date with any special default values? I would suggest that you set up your Fdate field in the database with a default value of Date() but offer the user the form field to fill in. Leave your coding alone and see if Access will deal with the record as it is entered into the database. On View.asp, do a DESC on your ID and pull the top record into that page for all to see.

Hope this helps.

M
&quot;There are 3 kinds of people; those that can count and those that can't&quot;
 
In case you hadnt guessed I stil haven't solved this.

View.asp

Is a page that displays entries in a database for a date. The default value of which is &quot;Date()&quot; unless there is a &quot;Request.Form(&quot;Fdate&quot;)&quot; value available. View.asp has a textfield on called &quot;Fdate&quot; and the forms properties are set to pass the &quot;Fdate&quot; value to View.asp. This means on the first load of the page the user sees any entries for today. They have the option on screen to then select another date, with the &quot;Fdate&quot; box.

My insert record page allows the user to enter whatever date they wish for their entry. what I want to happen is once the new entry has been inserted into the database the user is then directed to View.asp. At the moment View.asp always displays &quot;Date()&quot; and what I want the page to display is the value entered into the &quot;Fdate&quot; box on the insert page.

Hopefully that may be a bit clearer now. It may not get me the answer but it may be clearer what I am trying to do.

MLawson unfortunately I need the recordset sorting on a Time field in the database so cant work off the latest ID field :-( The secret of life is honesty and fair dealing. If you can fake that, you've got it made.
Groucho Marx (1895-1977)
 
I see whats happening - by default the page is always showing the current date. Where after if they enter items you want them to see all items for that date they just entered which can be a date other than the current one.

If I understand the navigation correctly.

User enters view.asp through more than one method. Once at View.asp they can click another link that will take them to a form entry page. Upon insertion that will take them back to view.asp.

Which as we know defaults to the current date.

you can't really tell view.asp to show something that hasnt happened. I'm surprised it works to begin with. I ran er am running into a similiar problem. the current date is always overriding whatever is inserted.

Solution - probably don't want to hear this - but create an identical view.asp pulling nothing but whatever was just entered. this page is only accessable by entering a form.


&quot;Insert witty remark here&quot;

Stuart
 
Your right I didnt want to hear that [thumbsup2]

never mind back to the drawing board The secret of life is honesty and fair dealing. If you can fake that, you've got it made.
Groucho Marx (1895-1977)
 
One last attempt.

Can anyone figure what is going on here.

My main page (default.asp) displays records from a database. At the top of the page I have the following code
++++++++++++++++++++
Dim Recordset1__MMColParam
Recordset1__MMColParam = Request.Form(&quot;Fdate&quot;)
if (Recordset1__MMColParam = &quot;&quot;) then Recordset1__MMColParam = Date()
++++++++++++++++++++

And on the page there is a form with
++++++++++++++++++++
<FORM name=&quot;form1&quot; method=&quot;post&quot; action=&quot;default.asp&quot;>
<INPUT type=&quot;date&quot; name=&quot;Fdate&quot; value=&quot;<%= (Recordset1__MMColParam) %>&quot;>
<INPUT type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;GO&quot;>
++++++++++++++++++++

So when the page is first loaded it displays the current date and users can navigate to other dates using the form to submit a date to the same page.

After inserting a new record, on another page, the user is sent to default.asp. The insert record page also has an input field called Fdate and I want default.asp to show the date that the user just inserted a record for but it always shows the current date. ??[mad] The secret of life is honesty and fair dealing. If you can fake that, you've got it made.
Groucho Marx (1895-1977)
 
Dim Recordset1__MMColParam
Recordset1__MMColParam = Request.Form(&quot;Fdate&quot;)
if request.querystring(&quot;gotdate&quot;)=&quot;&quot; then
if (Recordset1__MMColParam = &quot;&quot;) then Recordset1__MMColParam = Date()

else
Recordset1__MMColParam = request.querystring(&quot;gotdate&quot;)
end if

The other page with no code shown when redirecting to default.asp add a parameter...

response.redirect default.asp?gotdate=request.form(&quot;FDate&quot;)

 
Hey Cheech,

I came across this as I was trying to do an insert into a drop down that is on a form page - without refreshing the dropdown.

It might work for you

val = Request(&quot;Select17&quot;)
If Left(val,2) = &quot;$$&quot; Then
val = Mid(val,3) ' strip off the $$
SQL = &quot;INSERT INTO optionListTable ... VALUES('&quot; & val & &quot;'...&quot;
conn.Execute( SQL )
End If


Let me explain a little further.

If in your case you have a form to be entered, put a $$ infront of the value to be inserted.

Like this: new Option(this.value, &quot;$$&quot;+this.value)

The first set of code - when you hit submit it strips the $$ off and inserts the record - and off you goto the next page.

Now if you carry the value along - do an IF statement saying If blah blah has the $$ then display that record. If it does not - display the current date.

Unfortunately that is about as far as I can go with it. But check out and post whats happening there.

Hopefully you see what I'm suggesting, maybe you can play with it and see what happens. &quot;Insert witty remark here&quot;

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top