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

Handling search/grid behavior when search results are 0

Status
Not open for further replies.

david7777777777

Programmer
Sep 26, 2001
417
US
Can someone point me in the right direction as to how I need to code and if statement for my grid if the search results in no recorde returned? I've got a simple SQL statement in my record set as follows:

SELECT LastName, FirstName, MiddleInitial, Department
FROM tbl_employees
WHERE Department = ?

I'm setting the parameter in code from a listbox DTC as follows:

Sub lstDepartments_onchange()
rsEmployees.setParameter 0,lstDepartments.getValue()
End Sub

Then I've got a command button opening the record set. If no records are returned, I'd like the page to remain in an appropriate mode to be able to immediately handle another attempt at a search with input by the user and prompt the user to "try again" with a message that says something like "no records found, try again..."
 
After the grid, try adding
<% if rsEmployees.recordCount() = 0 then
Response.Write &quot;No emplyees here - Try Again!&quot;
%>

If you are confident you can change the grid DTC code to add a Empty Recordset message property - that is printed whenever the grid is empty.

Your onchange method should then close/open the recordset. (Content Management)
 
I tried adding that piece of server code and it doesn't like it. It wouldn't even load the page so traces were not available. I tried to type the code manually and when the little drop-down window opened that shows all the available properties or methods for the record set, &quot;recordCount&quot; was not in the list. Does this matter?
 
It didn't like that either, but thanks for the help. I'll have to dust off my Visual Basic book or JavaScript book to write some client-side code I guess. Feel free to toss me any more clues if you have any though. Thanks.
 
yes, I understand that this is server-side code, but that's the problem: I don't know what I need, client or server code. How do I determine what I need: what is the criteria for determining this?
 
I assume here that you have a combo, and depending on the selection, either a grid shows or not..

Well, for client side code you:
load up an array with all of the details that could be displayed in the grid - and then a load of javascript to dynamically create the table elements. This is the essence of RDO and client-side data-binding objects - but these tend to only work in IE.

For Server Side code you:
cause a submit to occur when the combo changes, then well you know the rest.

Off to the office party now! (Content Management)
 
I'm pretty JavaScript ignorant, I'm going to get my book out. Our office party is tomorrow. It's at
Enjoy the party. If you make it to work tomorrow then you did not properly enjoy the party!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top