checkbox true

G

Guest

Hi, I have a form that when I check the deceased checkbox I would like the
form to either change colors or a msg box to pop-up.
I've tried
If Deceased = True Then
MsgBox "PATIENT IS DECEASED"
End If

That only works on my click event. any thoghts would be appreciated.
 
M

Marshall Barton

coconutt said:
Hi, I have a form that when I check the deceased checkbox I would like the
form to either change colors or a msg box to pop-up.
I've tried
If Deceased = True Then
MsgBox "PATIENT IS DECEASED"
End If

That only works on my click event. any thoghts would be appreciated.


You probably want to use the same code in the form's Current
event:

Sub Form_Current(
If Deceased = True Then
Me.Section(0).BackColor = vbRed
End If
 
G

Guest

I need the msg box to appear everytime the patient's record has focus. So if
I click next and then come back the msgBox would re-appear?
 
M

Marshall Barton

coconutt said:
I used this code and it seems to color all records red. Any thoughts?


Ahhh, your form is displayed in continuous or datasheet
view. Without using any code, you can get the desired
effect by adding a text box with no attached label.
Position and size the text box so it fills the entire detail
section and use the Format - Send To Back menu item to put
it behind all the other controls. You may also want to set
the other controls, or just the labels, BackStyle property
to Transparent.

With that in place you can use the Format - Conditional
Formatting menu item to change the new text box's BackColor
when the expression Deceased = True is satisfied.

If you really want the message box instead of a different
color, then the code you had before will work in the Current
event since it doesn't change any properties.
 
M

Marshall Barton

Marshall said:
Ahhh, your form is displayed in continuous or datasheet
view. Without using any code, you can get the desired
effect by adding a text box with no attached label.
Position and size the text box so it fills the entire detail
section and use the Format - Send To Back menu item to put
it behind all the other controls. You may also want to set
the other controls, or just the labels, BackStyle property
to Transparent.

With that in place you can use the Format - Conditional
Formatting menu item to change the new text box's BackColor
when the expression Deceased = True is satisfied.

If you really want the message box instead of a different
color, then the code you had before will work in the Current
event since it doesn't change any properties.


Whoops. It looks like I implied that you can get the
desired effect on a form in datasheet view. That is not the
case.

If your form was being displayed in datasheet view, you will
have to change it to Continuous view, generally a fairly
easy thing to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top