the only way ...off the top of my head is either to bring in all posts for that thread and work out (like in the forum_posts.asp), not realistic on performace issue
or a more realistic idea..
is when you post a message a new field is stored in the threads table with Page_ID, and when the post is submitted send the page it is on an work out if its a new page or not. easy to do. the calculating same as ussual.
then when searching, bring in the pageID from the threads table and add it to the URL string.