Discussion Locked

Intercept "NO Data" with message

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have an Access 97 database. Members is the main table. Dependents is the child table. One Member has many Dependents.
I have a Member form with 3 buttons. Dependents Form - Dependents Report and Exit.

All works great when there ARE Dependents.

When there are no dependents I get a blank Form. With the report, it is mostly blank with an error because of the count at the end.

Is there any way to intercept the form and the report and pop up a box saying "Member XXXXXX has NO DEPENDENTS.Click OK to return to the Member form??????????

Thanks for your help!

Alan

5 replies

by gary_w

I'm rusty on Access but what you want to do is run a query that selects a dependant count whenever a new member is selected.

If the count is > 0
then go to dependant form
else pop up your message
end if

good luck,
Gary

by bob sellman

I assume that you do not want most people to be able to add dependents, since the form will be blank unless the Allow Additions property is set to true (which means the form will always have a blank new row displayed). If this is the case, then setthe dependents form on open property to do a count of the dependents and if it is 0, then make a label box that says "No dependents" visible on the form. (Set the visible property of the label box to normally be false.)

If you want to use buttons to bring up another form that displays dependents, why not (on the members form) do the count of dependents and then do the following:

' me.MemberNbr is the member ID control on the Members form.
' lblNoDep is the label that reads "No Dependents" on the member form. (You might place this on top of the Dependents button.)
' cmdDependents is the button to call up the dependents form

lngDepCount = Dlookup("[DepName]","[Dependents]","[MemberNbr] = " & me.MemberNbr)
if lngdepcount = 0 then
me.cmdDependents.visible = true
me.lblNoDep.visible = false
else
me.cmdDependents.visible = false
me.lblNoDep.visible = true
end if

You might also consider modifying your members form to use tabs, rather than the buttons. One tab could show the regular member information. The second tab would contain the dependents form (linked via the member number). The interface is much cleaner with the tabbed form that popping up new forms. You could still use the same concept as abovewith the button/message label, except you would set the dependents tab visible property to false when there are no dependents.

Use the same concept in your report to print a line that says "No dependents" rather than the dependent list. (You might put the dependent list in a subreport on the report.)

This discussion is closed to new replies.