CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Record form is blank.

Print topic Send  topic

Author Message
drc
Posted: 01/23/2002, 7:50 PM

How might I go about getting my "record" type form (form2)to display the newest table record when it opens? It currently opens to no record at all. I can click a link in another form (form1) to load a desired record in form2. But form2 starts up blank and this is undesirable.

Thanks,
Donna
drdisk
Posted: 01/23/2002, 9:32 PM

You can call you form2 like this www.yoursite.com/form2.asp?form2_id=3&
form2_id is your primary key no. for that table. So whatever record you want to edit just use that number. if you last record is 50 then you would use form2.asp?form2_id=50&

my table is users so I use members.asp?users_id=5&
I hope this helps you.
Harry

Andrew B
Posted: 01/23/2002, 10:09 PM

Well, you might do something like what I have below. I haven't tested it, and you will have to replace my var. names with your own, but I think this will work.

You need to change userid to whatever the PK you are passing into the form normally to select a record. If it is "page.asp?myID=3" then you would change userid to 'myID' (case insensitive).

You select the top one using sql, and retrieve that single value. You will want to change the orderby field to be the autonumber field in your DB, and the DESC makes it sort from highest value to lowest (newest to oldest).

if (GetParam("userid") = empty) then
dim myRs
sSql = "SELECT top 1 FROM table_name ORDER BY user_id DESC"
userID = cn.execute(sSql).fields(0).value 'get the one and only returned
end if
Donna
Posted: 01/24/2002, 5:04 AM

it would require me to manually change the link everytime I add an article to the table. I have a table field named date_posted and would like to have the newest article display, based on the date. I'm using the timestamp so sorting that field is no problem (DESC). I am a CC, PHP & mySQL newbie so I really like the idea of solving the problem within the url. Can this be accomplished?

Thank you for the help!
Donna
Donna
Posted: 01/24/2002, 5:12 AM

Thank you for your help, Andrew. I'm sorry, I should have specified that I'm using mySQL and PHP. This is all new to me and I'm not sure where to change the needed settings. Is this correct: The code you posted should go in the forms "Before Show" Event?...

(php version of this code needed)
<<begin code>>>
if (GetParam("userid") = empty) then
dim myRs
sSql = "SELECT top 1 FROM table_name ORDER BY user_id DESC"
userID = cn.execute(sSql).fields(0).value 'get the one and only returned
end if
<<end code>>

Do I need to set anything else up, i.e. the form's INPUT parameters?

Thank you for your patience,
Donna

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.