Conditionaly Protect Form Fields

A

Alvin

I have an option group "Radio Buttons"
"Protect" and "Un-Protect". I would like the user to have this option so a
msgbox can red flag and Remind them about Changing an Animals name.
I have a form where I enter Animals. Once the info is entered I would like
to protect that info. What I am saying is this.
I am breeding animals. If say one of the male breeders die I still need his
info in the database if he is the father of any of the other animals and the
only way I would want to be able to delete him is if he has absolutly no
relationship to another animal otherwise his info will be needed because he
is the father of another animal.
I have radio buttons in the code below.
Here is what I have so far but not sure what to do from here.
My autonumber for all animals is "[AnimalID] and name field is [AnimalName]
if that helps. Thanks in Advance.
Alvin
---------- My Code so far---------------------
If Me.Protect = yes Then
MsgBox "If You Un-Protect This Animal" & Chr(13) & Chr(10) & Chr(10) &
"You May Accidently Erase Information That Could Cause Data To Be Displayed
Incorrectly!" & Chr(13) & Chr(10) & Chr(10) & "Are You Sure You Want To
Un-Protect ( " & [Form_Add Male Breeders]![AnimalName] & " ) At This Time?" &
Chr(13) & Chr(10) & Chr(10) & "If Not! After You Click OK Click On Protect",
vbOKCancel, Cancel = True
Me.Protect = yes
Else
MsgBox "You Have Succesfully Protected ( " & [Form_Add Male
Breeders]![AnimalName] & " ) At This Time?", vbCritical, "Both Are Female"
End If
----------End code-----------------------
 
M

Marshall Barton

Alvin said:
I have an option group "Radio Buttons"
"Protect" and "Un-Protect". I would like the user to have this option so a
msgbox can red flag and Remind them about Changing an Animals name.
I have a form where I enter Animals. Once the info is entered I would like
to protect that info. What I am saying is this.
I am breeding animals. If say one of the male breeders die I still need his
info in the database if he is the father of any of the other animals and the
only way I would want to be able to delete him is if he has absolutly no
relationship to another animal otherwise his info will be needed because he
is the father of another animal.
I have radio buttons in the code below.
Here is what I have so far but not sure what to do from here.
My autonumber for all animals is "[AnimalID] and name field is [AnimalName]
if that helps. Thanks in Advance.
Alvin
---------- My Code so far---------------------
If Me.Protect = yes Then
MsgBox "If You Un-Protect This Animal" & Chr(13) & Chr(10) & Chr(10) &
"You May Accidently Erase Information That Could Cause Data To Be Displayed
Incorrectly!" & Chr(13) & Chr(10) & Chr(10) & "Are You Sure You Want To
Un-Protect ( " & [Form_Add Male Breeders]![AnimalName] & " ) At This Time?" &
Chr(13) & Chr(10) & Chr(10) & "If Not! After You Click OK Click On Protect",
vbOKCancel, Cancel = True
Me.Protect = yes
Else
MsgBox "You Have Succesfully Protected ( " & [Form_Add Male
Breeders]![AnimalName] & " ) At This Time?", vbCritical, "Both Are Female"
End If
----------End code-----------------------


Your radio buttons have a True or False value, even if the
field type is called Yes/No. Try changing the yes to True
in both place it's used.

Have you looked into using Referential Integrity to prevent
parent records from being deleted?
 

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