Jane,
If you have a common field between the table of
information of your main form and the table of information
that you plan on using as the source for showing the
additional contacts, all you would have to do is
1. Build a query for the form that is going to be
opened. In that query have all of the fields that are
going to show on the form, plus the field that is common
to the table that is used for your main form.
2. While in design mode of the new query for your form
that is going to be called. Place in the criteria for the
common field the following:
[forms].[yourmainformname].[textboxcommonfield]
Use forms as listed above,instead of using
yourmainformname as above use the name of your main form,
and instead of textboxcommonfield as above use the text
box name from your main form that holds the field
information that is common to both your main form and the
form being called.
3. Build a form using the new query you have built.
4. Create a button on your main form, for the onclick
property of that button, assign a macro that makes the
action of openform, and assign the form to be opened as
your new form.
Now at this point you have your button which will
open the new form from your main form, and the new form
that is opened will hold only records that are common to
the sources for both forms.
5. What you can do now to assign the message you were
mentioning is to note in the next action of your button
macro (macro design view in the conditions column, if you
can't see the column, click view and select conditions)
whether the form that has been called has a null field in
it or not. You would enter something like this in the
conditions column, remember you are on the second line of
the macro, like this:
isnull([forms].[formcalledname].[textboxoncalledform])
but you would use the name of the form being called,
instead of the formcalledname as above, and you would use
the name of the text box on the form being called, instead
of the textboxoncalledform as above. Now in the action
column of the same level as the condition you just entered
select the action msgbox, and in the Message specification
on the lower part of the design view of the macro type the
message that you want displayed.
Save your macro, and open your main form, use your
button, and the called form should open showing any
records that are relevant to your main form, if there are
no records in the form that has been opened relevant to
the main form, the message box should display itself.
The other thing you wanted to do is done in a
somewhat similar way as the other message box, but will
have different conditions.
I hope the information I gave you will help.
Casey
-----Original Message-----
I've got a database based on the Contact Management template. I would like
to add two control buttons to the form to 1) Open a window to display a
listing of all additional contacts relevant to that record and 2) Open a
form to add additional contacts to the record.
This seems a terribly easy task but I can't seem to make the buttons more
sophisticated. I'd like a message to appear telling the user that there are
no additional contacts where there are none. And I'd like the 'Add Contact'
button to cancel if no contact is added. (both forms are based on tables,
by the way). Many thanks for any light shed.
.