OK,
What I did was create a switchboard which then the user can select to run a
search for an employee.
This then runs a query which asks for a parameter from the user "Enter Last
Name", then opens in a form that I made.
By request from the user they wanted a button on that form to allow them to
search for another employee without having to go back to the switchboard.
So I added a command button to run the query again.
Everything worked just fine until you entered a name that was not in the
database, then you just got a grayed out box.
With your help I fixed the problem when you run the query from the
switchboard, however when you use the command button from the form it still
does it the other way. It is fine if the form grays out, I just want it to
prompt the user what is going on and that they should close and return to the
switchboard. That is assuming that I can not get it to automatically close
and return to the switchboard.
Thanks
Eric
theDBguy said:
Hi 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.
Hope that helps...
:
Ahh finally works
Thanks
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
:
Hi Eric,
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...
:
I have a query that when run opens into a form, however when there is no
matching record in the database the form opens as a grayed out box. This is
fine for me because I can get around in the database just fine, but this
database is to be used by other users, so I am trying to eliminate this
problem. It was suggested to me to have the query look and see if a record
exists before opening the form.
So my question is, is this the right thing to do and if so how do you do it?
The query runs a search for an employee using the field - [Last Name]
Thanks