The query runs a search for an employee using the field - [Last Name]
Thanks
IMHO you open a form that uses the query. Therefore the solution is
with opening the form.
Use a button on a form to open the form and commands like these in the
click event of the button:
If DCount("*", "YourQuery") > 0 Then
DoCmd.OpenForm "YourForm"
Else
MsgBox "No data te be diplayed on the form"
End If
Groeten,
It seems dangerous to use only last name since there could be many different
people with the same last name surely?
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
I agree with the others of using a form. So, here's another possible
solution (really just a variation of the others already given). In the form's
Open event:
If Me.Recordset.BOF And Me.Recordset.EOF Then
Msgbox "Sorry, no record found.", vbOKOnly, "No Record Found!"
Cancel = True
End If
Hope that helps...
One more question
I added a command button to the form to re-run the same query. Is there
somewhere I need to add that code to also get the desired results?
Eric
Where did you add the button? On the same form you are opening earlier? If
so, where is the parameter coming from? To requery the form, you would use
Me.Requery
but I suspect that there is a portion of this scenario that I am missing.
Don't you want to close the form first before you do the requery? If not, you
could try repeating the original code in the form's Current event.
Thanks
Thanks
Can you post the code you are using for your button? Have you tried also
putting the code I gave you earlier in the form's Current event?
I did put the code in the form's current event, however still no luck
The problem is...
1. Enter parameter value...
2. Form opens already filtered
3. You Me.Requery is only requerying the filtered query
You're going to need something like...
Me.Filter = ""
Me.Requery
OR
Me.RecordSource = "Query" 'Though not sure if this will work with a
parameter
However, if it where me, I have them open a form and have them select the
parameter value directly on the form that opens. Would give you a wee bit
more control and you could have a [Set Filter] and [Clear Filter] button.
You could also filer by more then Last Name.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" - Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
"Eric Starn" <Eric...@discussions.microsoft.com> wrote in message
news:4068F1FD-CB8D-4F12...@microsoft.com...