Forums

This topic is locked

Search & Results on same page & show if empty.

Posted 27 May 2003 10:31:59
1
has voted
27 May 2003 10:31:59 James Wilkinson posted:
I am building a search page and want the results to appear on the same page. This is easy to do but I also want to add a message that shows if no results are found.

The problem i am having is that when you open the search page the Show if Recordset is empty region is showing as the recordset is empty to begin with.

Any ideas? or do I have to have the results on a different page?

Any help would be greatly appreciated.
slink.

Replies

Replied 29 May 2003 16:34:16
29 May 2003 16:34:16 Lee Diggins replied:
Hi slink

I'm not sure what server you're using so I'll describe the solution.

You need to check if the BOF and EOF are true, when they are the recordset is empty. Add your code to write your message to the screen, then close the if statement.

That's about it I think.

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 29 May 2003 18:53:05
29 May 2003 18:53:05 James Wilkinson replied:
Hi Digga,

sorry I am using .asp with VBScript.

As I have the results appearing on the same page as search function, the page already checks if BOF and EOF are false so that it doesn't show the first record in the recordset.

Then if I add a show if BOF and EOF are true, this section show up as soon as you open the page.

how do I get it to only show after they have searched?
thanks for you previous response digga.
slink.
Replied 30 May 2003 10:30:10
30 May 2003 10:30:10 Lee Diggins replied:
Hi slink

Ok think I understand the issue...

I get around this by adding a hidden textfield to the search form with a default value of 1. When you post the form the value 1 lets you know it's not the first time this page was accessed, so a check for BOF and EOF and the hidden field lets you know that the search results are empty after doing a search, the same check also tells you if this is the first time you've accessed the page.

I hope I've explained this in a way so you can understand what's going on. Give this a try and if you have any problems, post the code form your asp page and I'll amend it accordingly.

Let me know how you get on.

Digga

Sharing Knowledge Saves Valuable Time!!!

Reply to this topic