Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set message visible if subform condition met 1

Status
Not open for further replies.

Joallyn

Technical User
Jul 26, 2002
44
US
Hello all,

I am working on an "Incident" database. For each incident that occurs, the fix-up crew can make multiple actions (reconn, clean-up, etc.) So I have a main form (frmIncidents) linked to a continuous subform (subfrmActions).

On the subform there is an option button that the user clicks to indicate that it's the last action. If clicked, the incident is complete. What I would like to do is display an "Incident Complete" message on the main form when this button value is true.

So, main form: frmIncidents
msg: lblIncidentComplete

subform: subfrmActions
option: optComplete

What I wrote is:

Private Sub Form_Current()
If Me!subfrmActions.Form![optComplete].Value = True Then
Me!lblIncidentComplete.Visible = True
Else
Me!lblIncidentComplete.Visible = False

End If

End Sub

However, the message never displays, even when the option button is toggled. Any ideas?

thanks in advance,

J
 
1) is the "completeness" a yes/no field in the INCIDENT record? If not, perhaps it should be.

2) Once it is, You're very close (like the veins in my legs):


Private Sub Form_Current()
with me
If !subfrmActions.Form![optBoxComplete] Then
!complete = True
!lblIncidentComplete.Visible = True
Else
!Complete = False
!lblIncidentComplete.Visible = False
End If
End with


..except I'm not sure I'd put this code in the form's current event. I might put it in the Option Box's AFTER UPDATE instead.

A yes/no field can be short-circuit tested just as you see:

If YesNoField
is the same as
IF YesNoField = TRUE/YES/-1

This should do the trick for you.

However, I have a slight philosophical problem with arbitrarily setting the "completeness" based on a mouse-click. There should be some logical/business rule related event that makes an incident COMPLETE, shouldn't there be? I could set an incident 'complete' with only one action, but then go add another action or three, and set the COMPLETE guy to FALSE and go on like this. To my somewhat befuddled mind, this may not be good.

Jim




Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
hi Jim,

thanks! I took your advice, and here's what I ended with:

Private Sub optBoxComplete_AfterUpdate()
With Me
If ![optBoxComplete] Then
.Parent!Complete = True
.Parent!lblIncidentComplete.Visible = True
Else
.Parent!Complete = False
.Parent!lblIncidentComplete.Visible = False
End If

End With

End Sub

So far, that all seems to work.

I absolutely agree with your philosophical objection to forcing the user to mark an incident "complete", but I'm stumped as how to otherwise identify it as such. I haven't yet come up with a common action that would automatically qualify each incident as closed.

If you have any ideas, I'd be happy to hear them!

Joallyn
 
Here's an even shorter method. Since you're setting the parent guys to the same value as the option box, you can cut out some of the code:


Private Sub optBoxComplete_AfterUpdate()
With Me
.parent!Complete = optBoxComplete
.parent!lblIncident.Visible = optboxComplete
End with


Do you see how that is the same as the earlier snippet?

Since a two-state option box has to (well, should..) be just one of two values, there's really no reason to say "if it's true, do this, or if it's false do this..", when you can just say "make this the same as the option box value"

It's unfortunate that there can be no logical rule applied to determine "completeness" - when this is the case, you have to guard against having this guy waffle back and forth, esp. if user safeguards are not comprehensive.

Jim





Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
Hi Jim,

what, you couldn't get it all into one line?!

Just kidding.

If I ever figure out how to set a rule for completeness, I'll take out this coding--but in the meantime you've made an elegant solution.

thanks again--

J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top