July 31st, 2004, 07:39 AM
|
#1 (permalink)
| | Junior Member
Join Date: Jul 2004
Posts: 11
| MS Access Database
Hi there;
Hope someone can help here, and the solution not bee to complicated.
What i want to do is create an error message for a filter, if it doesn't return any entries, rather than showing a blank version of the form.
This is annoying and doesn't explain why the form is blank to whoever is using it.
Is there anything i can do???
Thanks.
Dan |
| |
August 1st, 2004, 05:48 AM
|
#2 (permalink)
| | Member
Join Date: Sep 2002
Posts: 364
|
Yes. How are you setting the filter? In code? |
| |
August 1st, 2004, 07:47 AM
|
#3 (permalink)
| | Junior Member
Join Date: Jul 2004
Posts: 11
|
No, not using code, i am using Access to filter it itself.
I'll explain, i have a form, that is a search box, when you click on "Search" access does the "open form and find specific data to display" and then brings up another form with the results in it.
When the form matches nothing, the form that comes up is blank with only the background colour visable. No buttons, no fields, nothing.
I just want either that box to display "your results turned up nothing," or an error message from a macro to say the same and close the form.
Something like that.
I'd appreciate any help, but i don't do Vis basic code.
Thanks
Dan |
| |
August 1st, 2004, 03:28 PM
|
#4 (permalink)
| | Member
Join Date: Sep 2002
Posts: 364
|
I am unfamiliar with what exactly you are doing. Did you create a form, then add a button, and choose one of the default Access buttons? If so, what did you pick, "Apply Filter", "Open Form", "Find a Record", or what?
What you want to accomplish is fairly easy, but I need to know exactly how your form is constructed now. |
| |
August 1st, 2004, 04:38 PM
|
#5 (permalink)
| | Junior Member
Join Date: Jul 2004
Posts: 11
|
When i set up the search form firstly i added a button by using the tool in the toolbox, which automatically opens the button wizard.
I then set it to open a form and selected the form i wanted it to open.
It then asked me to select either;
"Open form and find specific data to display" or
"Open the form and display all records"
I selcted the first one, "find sepcific data to display,"
after that it gave me a list of available fields to match the data with; so i selcted the fields from both tables that the filter had to match.
field one.table one<->anotherfield.tabletwo (sort of thing)
and thats it...
hope it helps, and you can help me. |
| |
August 1st, 2004, 11:24 PM
|
#6 (permalink)
| | Member
Join Date: Sep 2002
Posts: 364
|
Well, I don't have that exact button, but I worked out what you are doing. Regardless, you will need to go into the VBA code of your 2nd form. Press Alt-F11 while in design mode. Paste in this code: Code: Private Sub Form_Load()
If Me.Recordset.BOF And Me.Recordset.EOF Then
MsgBox "There are no records to display."
End If
End Sub |
| |
August 2nd, 2004, 02:22 PM
|
#7 (permalink)
| | Junior Member
Join Date: Jul 2004
Posts: 11
|
That has helped, but i have a further question,
as well as that code opening a msg box, can i make it close that form and go back to the form before it, or run a macro that willo do that?
thanks again;
Dan |
| |
August 2nd, 2004, 10:09 PM
|
#8 (permalink)
| | Member
Join Date: Sep 2002
Posts: 364
|
Add a DoCmd.Close in there after that Msgbox statement. |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |