As I said, if your parameter is created by adding Like [Enter Surname] & "*"
to the grid, there is no way to invoke a message box if the user doesn't
provide a name.
Your only option is to have a form that has a text box named, say,
txtSurname, change the criteria in the query to Like
[Forms]![MyFormName]![txtSurname] & "*" and have a command button on the
form that launches the query. In the Click event of that command button,
you'd check to ensure whether txtSurname was filled in. If it wasn't, you'd
have a message box pop up. Otherwise, you open the query. There is no
alternative.
As to having a message if the query's empty, that can't be done with a
query. You'd need to open a form, and put logic in its Open event to
determine whether or not any data was returned, and pop up an appropriate
message box if not.
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Dermot said:
Thanks for the reply Douglas
Can you advise further?
I appreciate your suggestion, which I think would be more relevent for
more
involved criteria, or multi criteria....if I have understood it correctly.
I am trying to understand how to incorporate message boxes, or it may be
conditional validation...not sure......but would like to know hope to
incorporate them.
I have created a single table with 2 columns, surname, phone number.
I then created a parameter query not using the parameter dialogue box just
the grid criteria field ....Like [Enter Surname] & "*"
This works fine but if the criteria box is left empty, I would like a
message box to request a surname....
Likewise....what is the best way to validate a surname entered....to
coinside with names in the table.....if not ...then a message box to state
"Entry not availab;e" or something similar......
Douglas J. Steele said:
If you're simply putting parameters into the query (such as having [Enter
Stock Number] in the criteria row of the query in the graphical builder),
there's no way for you to give them "a second chance" such as you're
looking
for.
On the other hand, you could create a form that room for all of the
necessary parameters on it (and you can use text boxes, combo boxes, list
boxes, check boxes, option groups or toggle buttons), have your query
point
to those controls on the form rather than generic parameters, and have a
Submit button on the form that double checks that values have been
provided
for each parameter before running the query.
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Can anyone advise me of the correct way to use a message box to
indicate
an
error if no criteria is enered into a parameter query.....ie...if some
one
just clicks okay without entering the query parameter, I would like a
message
"Please enter such and such" if you know what I mean?
Where do I set this up.......in the query?