the thing to understand with forms is that they reload the page.
you say:
"I have a form in which I pass to it a key value for a database table lookup."
I suspect this is a querystring value, right? for example:
pagename?id=4
when the form submits, it causes the page to reload.
the form uses the action attribute to tell the server what page to load, if the querystring variable is not included in the action attribute, it will cause the recordset to return an empty data set.
you can use the following code for the form action:
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".htmlspecialchars($_SERVER["QUERY_STRING"]):""; ?>"
this will automatically include any querystring values that are passed into the page when the form submits.