Check box

J

JoAnn

I would like to create a field in a form that asks a
yes/no question and then takes the yes and makes it two
words ("no degree" if checked) in the corresponding
field. Can someone tell me how to do that?

Then, if checked the following fields on that tab of the
form can not be completed. The following fields being:
degree, university, year etc.
 
T

tina

in the checkbox's AfterUpdate event procedure and the form's Current event
procedure, call the following sub, as

Private Sub CheckDegreeFields()

With Me
.DegreeControlName.Enabled = Not .MyCheckboxName
.UniversityControlName.Enabled = Not .MyCheckboxName
.YearControlName.Enabled = Not .MyCheckboxName

If .MyCheckboxName Then
.MyTextboxName = "No degree"
Else
.MyTextboxName = Null
End If
End With

End Sub

in addition, add the following code to the checkbox's AfterUpdate event
procedure, as

With Me
If .MyCheckboxName Then
.DegreeControlName = Null
.UniversityControlName = Null
.YearControlName = Null
End If
End With

substitute the correct control names, of course. the above assumes that the
checkbox control is bound to a Yes/No field in the form's underlying table.
it further assumes that the other controls are also bound to table fields,
with the exception of MyTextboxName.

hth
 
J

JoAnn

The form's current event procedure would not allow me to
name CheckDegreeFields(). It defaulted to FORM. Below
is the sub copied from the code. I get the following
error for each line with no degree in it:

compile error: Expected: end of statement


Private Sub Form_Current()
With Me
.Degree.Enabled = Not .No Degree
.University.Enabled = Not .No Degree
.Year Graduated.Enabled = Not .No Degree
.Major/Discipline.Enabled = Not .No Degree
.Specilization.Enabled = Not .No Degree

If .No Degree Then
.No Degree = "No degree"
Else
.No Degree = Null
End If
End With

End Sub

Any suggestions???
 
T

tina

this is a classic example of why you shouldn't put spaces (or any special
character except the underscore) in field names (or table names, or any
other object names, in fact) - it causes headaches when you're trying to
write code.
i *think* underscore will work, as

.Degree.Enabled = Not .No_Degree

if it doesn't, post back and i'll try to talk you thru an alternative.
though personally, unless you've already written a lot of forms, queries,
reports and code that refer to this field, i'd go back and change it at the
table level (removing the space) and fix the necessary references in
queries, forms, reports, code. then it would be right and the problem
wouldn't arise again.
also to call the sub CheckDegreeFields as instructed in my previous post,
the form's Current event procedure should look like this:

Private Sub Form_Current()

CheckDegreeFields

End Sub

the checkbox's AfterUpdate event procedure should look like this:

Private Sub MyCheckboxName_AfterUpdate()

CheckDegreeFields
With Me
If .MyCheckboxName Then
.DegreeControlName = Null
.UniversityControlName = Null
.YearControlName = Null
End If
End With

End Sub

again, substitute the correct control names.

hth
 
J

JoAnn

Thanks for all you help Tina! I don't have the
experience it takes to write this kind of code. I
appreciate all your additional help.
 
Top