Discussion Locked

Access 97 Problem

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

I have a list of names. When I click on a name the member record comes up. I then use a Command button to bring up the Member's Dependents. If there are NO dependents, I need a message to pop up saying NO Dependents. Ortherwise, the dependent form comes up.

I would gladly email you a copy of the cut down application (876K). I've tried all the regulat things and they don't work. Perhaps bacause I used a subform with the dependents.

Just Email me at abramowitza@coned.com and I will send youthe mdb file.

Thanks so much for any help you can offer....

Alan

8 replies

by gary_w

On click of the command button, do a select to get the count of the dependants.
if count > 0
go to new form
else
display message

Gary

by mra2

Gary,

Give me some sample code for the count and how to address that code in the Visual Basic for Apps code, please.

I have not been able to get that to work....

by dsa

Just use a function that opens the pop up form when there is a dependent and opens the message box if there is none similar to the function I recommended to you before on the postdate. Just call this function in the on_Click event procedure.

by bob sellman

First, determine if there are any dependents:

dim lngCount as Long

lngCount = DCount("[DepName]","[Dependents]","[MemberID]=" & me.txtMemberID)

' me.txtMemberID is the control on your form where you select the member (or the control that contains the member's ID #). If the member ID is a string, remember to surround it with single quotes as in: "[MemberID] ='" & me.txtMemberID & "'"

You can still use the subform. Make a label the size of the subform that says "No Dependents" and put it over the same location as the subform. Set visible property to false. Then make either the subform or the no dependents notice visible as appropriate:

if lngCount = 0 then ' no dependents
me.txtSubForm.visible = false
me.lblNoDep.visible= true
else
me.txtSubForm.visible = true
me.lblNoDep.visible = false
end if

If you want a message to pop up with a separate form, just substitute the code to bring up your pop up form in place of the statements that set the visible properties.

This discussion is closed to new replies.