Yes/No Validation in subform

H

Hilarys

I have a student registration database with a main form, Cont_Regist_Form,
with the SessionID and SessionDate with a continuous subform named
Cont_Regist_Subform with the PupilID, PupilName and Yes/No check boxes for
Present and Absent linked via the SessionID.
To prevent pupils being accidently marked in as both present and absent I
have set the Validation on the Absent check box in the subform as ([Present]
Is Null). This works but throws up an error message if the pupil has been
marked as Present at ANY session. Could someone give me an expression/code to
link the validation to the SessionID in the main form?
This is probably very basic but I am new to Access.
 
G

Graham R Seach

Hilary,

You don't need two checkboxes for that. You can get away with only one =
Present. If it's value is True, the student is present, otherwise they're
absent. Problem solved without validation.

If you absolutely want two buttons, change them to Option Boxes, and place
them inside an Option Group, which forces only one of them to be checked at
any one time. Again, problem solved without validation.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
H

Hilarys

Impressed by your prompt response!
I'm afraid its a bit more complicated than that. I have the subform in
datasheet view so that I can scroll quickly down the Present 'column' using
the down key (rather than having to labouriously tab across each row if it
was in normal view) and option groups just show up as numbers in Datasheet
view. Also not all the students register at each session so I would have to
have 3 options Prsent/Absent/not registering. I have already set up several
crosstab queries etc which calculate their average attendance etc based on
the Yes/no check boxes so I would prefer to stick to these if possible.
sorry to be difficult.


Graham R Seach said:
Hilary,

You don't need two checkboxes for that. You can get away with only one =
Present. If it's value is True, the student is present, otherwise they're
absent. Problem solved without validation.

If you absolutely want two buttons, change them to Option Boxes, and place
them inside an Option Group, which forces only one of them to be checked at
any one time. Again, problem solved without validation.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Hilarys said:
I have a student registration database with a main form, Cont_Regist_Form,
with the SessionID and SessionDate with a continuous subform named
Cont_Regist_Subform with the PupilID, PupilName and Yes/No check boxes for
Present and Absent linked via the SessionID.
To prevent pupils being accidently marked in as both present and absent I
have set the Validation on the Absent check box in the subform as
([Present]
Is Null). This works but throws up an error message if the pupil has been
marked as Present at ANY session. Could someone give me an expression/code
to
link the validation to the SessionID in the main form?
This is probably very basic but I am new to Access.
 
G

Graham R Seach

Hilary,

Open the subform in design view. Then add the appropriate code to each
checkbox's Click event:

Private Sub chkPresent_Click()
Me!chkPresent = Not Me!chkAbsent
End Sub

Private Sub chkAbsent_Click()
Me!chkAbsent = Not Me!chkPresent
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Hilarys said:
Impressed by your prompt response!
I'm afraid its a bit more complicated than that. I have the subform in
datasheet view so that I can scroll quickly down the Present 'column'
using
the down key (rather than having to labouriously tab across each row if it
was in normal view) and option groups just show up as numbers in Datasheet
view. Also not all the students register at each session so I would have
to
have 3 options Prsent/Absent/not registering. I have already set up
several
crosstab queries etc which calculate their average attendance etc based
on
the Yes/no check boxes so I would prefer to stick to these if possible.
sorry to be difficult.


Graham R Seach said:
Hilary,

You don't need two checkboxes for that. You can get away with only one =
Present. If it's value is True, the student is present, otherwise they're
absent. Problem solved without validation.

If you absolutely want two buttons, change them to Option Boxes, and
place
them inside an Option Group, which forces only one of them to be checked
at
any one time. Again, problem solved without validation.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Hilarys said:
I have a student registration database with a main form,
Cont_Regist_Form,
with the SessionID and SessionDate with a continuous subform named
Cont_Regist_Subform with the PupilID, PupilName and Yes/No check boxes
for
Present and Absent linked via the SessionID.
To prevent pupils being accidently marked in as both present and
absent I
have set the Validation on the Absent check box in the subform as
([Present]
Is Null). This works but throws up an error message if the pupil has
been
marked as Present at ANY session. Could someone give me an
expression/code
to
link the validation to the SessionID in the main form?
This is probably very basic but I am new to Access.
 
H

Hilarys

Thanks,that works! The only thing now is that you can't uncheck the boxes
once they have been checked, so for instance if you mark a pupil as being
present then find you have made a mistake you can't edit the check box.

Graham R Seach said:
Hilary,

Open the subform in design view. Then add the appropriate code to each
checkbox's Click event:

Private Sub chkPresent_Click()
Me!chkPresent = Not Me!chkAbsent
End Sub

Private Sub chkAbsent_Click()
Me!chkAbsent = Not Me!chkPresent
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Hilarys said:
Impressed by your prompt response!
I'm afraid its a bit more complicated than that. I have the subform in
datasheet view so that I can scroll quickly down the Present 'column'
using
the down key (rather than having to labouriously tab across each row if it
was in normal view) and option groups just show up as numbers in Datasheet
view. Also not all the students register at each session so I would have
to
have 3 options Prsent/Absent/not registering. I have already set up
several
crosstab queries etc which calculate their average attendance etc based
on
the Yes/no check boxes so I would prefer to stick to these if possible.
sorry to be difficult.


Graham R Seach said:
Hilary,

You don't need two checkboxes for that. You can get away with only one =
Present. If it's value is True, the student is present, otherwise they're
absent. Problem solved without validation.

If you absolutely want two buttons, change them to Option Boxes, and
place
them inside an Option Group, which forces only one of them to be checked
at
any one time. Again, problem solved without validation.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

I have a student registration database with a main form,
Cont_Regist_Form,
with the SessionID and SessionDate with a continuous subform named
Cont_Regist_Subform with the PupilID, PupilName and Yes/No check boxes
for
Present and Absent linked via the SessionID.
To prevent pupils being accidently marked in as both present and
absent I
have set the Validation on the Absent check box in the subform as
([Present]
Is Null). This works but throws up an error message if the pupil has
been
marked as Present at ANY session. Could someone give me an
expression/code
to
link the validation to the SessionID in the main form?
This is probably very basic but I am new to Access.
 
D

Douglas J. Steele

I think Graham may have mixed them up. Try:

Private Sub chkPresent_Click()
Me!chkAbsent = Not Me!chkPresent
End Sub

Private Sub chkAbsent_Click()
Me!chkPresent = Not Me!chkAbsent
End Sub

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hilarys said:
Thanks,that works! The only thing now is that you can't uncheck the boxes
once they have been checked, so for instance if you mark a pupil as being
present then find you have made a mistake you can't edit the check box.

Graham R Seach said:
Hilary,

Open the subform in design view. Then add the appropriate code to each
checkbox's Click event:

Private Sub chkPresent_Click()
Me!chkPresent = Not Me!chkAbsent
End Sub

Private Sub chkAbsent_Click()
Me!chkAbsent = Not Me!chkPresent
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Hilarys said:
Impressed by your prompt response!
I'm afraid its a bit more complicated than that. I have the subform in
datasheet view so that I can scroll quickly down the Present 'column'
using
the down key (rather than having to labouriously tab across each row if
it
was in normal view) and option groups just show up as numbers in
Datasheet
view. Also not all the students register at each session so I would
have
to
have 3 options Prsent/Absent/not registering. I have already set up
several
crosstab queries etc which calculate their average attendance etc
based
on
the Yes/no check boxes so I would prefer to stick to these if possible.
sorry to be difficult.


:

Hilary,

You don't need two checkboxes for that. You can get away with only one
=
Present. If it's value is True, the student is present, otherwise
they're
absent. Problem solved without validation.

If you absolutely want two buttons, change them to Option Boxes, and
place
them inside an Option Group, which forces only one of them to be
checked
at
any one time. Again, problem solved without validation.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

I have a student registration database with a main form,
Cont_Regist_Form,
with the SessionID and SessionDate with a continuous subform named
Cont_Regist_Subform with the PupilID, PupilName and Yes/No check
boxes
for
Present and Absent linked via the SessionID.
To prevent pupils being accidently marked in as both present and
absent I
have set the Validation on the Absent check box in the subform as
([Present]
Is Null). This works but throws up an error message if the pupil has
been
marked as Present at ANY session. Could someone give me an
expression/code
to
link the validation to the SessionID in the main form?
This is probably very basic but I am new to Access.
 
H

Hilarys

That's cool!! But I still need to have the option for neither of the boxes to
be checked (not all the student on my list will be registering on that day).
I can acheive this by skipping over the records (pupils ) who are not
registering that day but if I tick one of them as Present or Absent by
mistake I cannot remove the tick with your coding in place.
Many thanks for your help

Douglas J. Steele said:
I think Graham may have mixed them up. Try:

Private Sub chkPresent_Click()
Me!chkAbsent = Not Me!chkPresent
End Sub

Private Sub chkAbsent_Click()
Me!chkPresent = Not Me!chkAbsent
End Sub

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hilarys said:
Thanks,that works! The only thing now is that you can't uncheck the boxes
once they have been checked, so for instance if you mark a pupil as being
present then find you have made a mistake you can't edit the check box.

Graham R Seach said:
Hilary,

Open the subform in design view. Then add the appropriate code to each
checkbox's Click event:

Private Sub chkPresent_Click()
Me!chkPresent = Not Me!chkAbsent
End Sub

Private Sub chkAbsent_Click()
Me!chkAbsent = Not Me!chkPresent
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Impressed by your prompt response!
I'm afraid its a bit more complicated than that. I have the subform in
datasheet view so that I can scroll quickly down the Present 'column'
using
the down key (rather than having to labouriously tab across each row if
it
was in normal view) and option groups just show up as numbers in
Datasheet
view. Also not all the students register at each session so I would
have
to
have 3 options Prsent/Absent/not registering. I have already set up
several
crosstab queries etc which calculate their average attendance etc
based
on
the Yes/no check boxes so I would prefer to stick to these if possible.
sorry to be difficult.


:

Hilary,

You don't need two checkboxes for that. You can get away with only one
=
Present. If it's value is True, the student is present, otherwise
they're
absent. Problem solved without validation.

If you absolutely want two buttons, change them to Option Boxes, and
place
them inside an Option Group, which forces only one of them to be
checked
at
any one time. Again, problem solved without validation.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

I have a student registration database with a main form,
Cont_Regist_Form,
with the SessionID and SessionDate with a continuous subform named
Cont_Regist_Subform with the PupilID, PupilName and Yes/No check
boxes
for
Present and Absent linked via the SessionID.
To prevent pupils being accidently marked in as both present and
absent I
have set the Validation on the Absent check box in the subform as
([Present]
Is Null). This works but throws up an error message if the pupil has
been
marked as Present at ANY session. Could someone give me an
expression/code
to
link the validation to the SessionID in the main form?
This is probably very basic but I am new to Access.
 
G

Graham R Seach

Thanks again Doug.

Hilary, try this:

Private Sub chkPresent_Click()
If (Me!chkAbsent = True) Then Me!chkPresent = False
End Sub

Private Sub chkAbsent_Click()
If (Me!chkPresent = True) Then Not Me!chkAbsent = False
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Hilarys said:
That's cool!! But I still need to have the option for neither of the boxes
to
be checked (not all the student on my list will be registering on that
day).
I can acheive this by skipping over the records (pupils ) who are not
registering that day but if I tick one of them as Present or Absent by
mistake I cannot remove the tick with your coding in place.
Many thanks for your help

Douglas J. Steele said:
I think Graham may have mixed them up. Try:

Private Sub chkPresent_Click()
Me!chkAbsent = Not Me!chkPresent
End Sub

Private Sub chkAbsent_Click()
Me!chkPresent = Not Me!chkAbsent
End Sub

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hilarys said:
Thanks,that works! The only thing now is that you can't uncheck the
boxes
once they have been checked, so for instance if you mark a pupil as
being
present then find you have made a mistake you can't edit the check box.

:

Hilary,

Open the subform in design view. Then add the appropriate code to each
checkbox's Click event:

Private Sub chkPresent_Click()
Me!chkPresent = Not Me!chkAbsent
End Sub

Private Sub chkAbsent_Click()
Me!chkAbsent = Not Me!chkPresent
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Impressed by your prompt response!
I'm afraid its a bit more complicated than that. I have the subform
in
datasheet view so that I can scroll quickly down the Present
'column'
using
the down key (rather than having to labouriously tab across each row
if
it
was in normal view) and option groups just show up as numbers in
Datasheet
view. Also not all the students register at each session so I would
have
to
have 3 options Prsent/Absent/not registering. I have already set up
several
crosstab queries etc which calculate their average attendance etc
based
on
the Yes/no check boxes so I would prefer to stick to these if
possible.
sorry to be difficult.


:

Hilary,

You don't need two checkboxes for that. You can get away with only
one
=
Present. If it's value is True, the student is present, otherwise
they're
absent. Problem solved without validation.

If you absolutely want two buttons, change them to Option Boxes,
and
place
them inside an Option Group, which forces only one of them to be
checked
at
any one time. Again, problem solved without validation.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

I have a student registration database with a main form,
Cont_Regist_Form,
with the SessionID and SessionDate with a continuous subform
named
Cont_Regist_Subform with the PupilID, PupilName and Yes/No check
boxes
for
Present and Absent linked via the SessionID.
To prevent pupils being accidently marked in as both present and
absent I
have set the Validation on the Absent check box in the subform as
([Present]
Is Null). This works but throws up an error message if the pupil
has
been
marked as Present at ANY session. Could someone give me an
expression/code
to
link the validation to the SessionID in the main form?
This is probably very basic but I am new to Access.
 
H

Hilarys

You are both Stars!! Thank you so much it works a treat.
Hilary

Graham R Seach said:
Thanks again Doug.

Hilary, try this:

Private Sub chkPresent_Click()
If (Me!chkAbsent = True) Then Me!chkPresent = False
End Sub

Private Sub chkAbsent_Click()
If (Me!chkPresent = True) Then Not Me!chkAbsent = False
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Hilarys said:
That's cool!! But I still need to have the option for neither of the boxes
to
be checked (not all the student on my list will be registering on that
day).
I can acheive this by skipping over the records (pupils ) who are not
registering that day but if I tick one of them as Present or Absent by
mistake I cannot remove the tick with your coding in place.
Many thanks for your help

Douglas J. Steele said:
I think Graham may have mixed them up. Try:

Private Sub chkPresent_Click()
Me!chkAbsent = Not Me!chkPresent
End Sub

Private Sub chkAbsent_Click()
Me!chkPresent = Not Me!chkAbsent
End Sub

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Thanks,that works! The only thing now is that you can't uncheck the
boxes
once they have been checked, so for instance if you mark a pupil as
being
present then find you have made a mistake you can't edit the check box.

:

Hilary,

Open the subform in design view. Then add the appropriate code to each
checkbox's Click event:

Private Sub chkPresent_Click()
Me!chkPresent = Not Me!chkAbsent
End Sub

Private Sub chkAbsent_Click()
Me!chkAbsent = Not Me!chkPresent
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Impressed by your prompt response!
I'm afraid its a bit more complicated than that. I have the subform
in
datasheet view so that I can scroll quickly down the Present
'column'
using
the down key (rather than having to labouriously tab across each row
if
it
was in normal view) and option groups just show up as numbers in
Datasheet
view. Also not all the students register at each session so I would
have
to
have 3 options Prsent/Absent/not registering. I have already set up
several
crosstab queries etc which calculate their average attendance etc
based
on
the Yes/no check boxes so I would prefer to stick to these if
possible.
sorry to be difficult.


:

Hilary,

You don't need two checkboxes for that. You can get away with only
one
=
Present. If it's value is True, the student is present, otherwise
they're
absent. Problem solved without validation.

If you absolutely want two buttons, change them to Option Boxes,
and
place
them inside an Option Group, which forces only one of them to be
checked
at
any one time. Again, problem solved without validation.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

I have a student registration database with a main form,
Cont_Regist_Form,
with the SessionID and SessionDate with a continuous subform
named
Cont_Regist_Subform with the PupilID, PupilName and Yes/No check
boxes
for
Present and Absent linked via the SessionID.
To prevent pupils being accidently marked in as both present and
absent I
have set the Validation on the Absent check box in the subform as
([Present]
Is Null). This works but throws up an error message if the pupil
has
been
marked as Present at ANY session. Could someone give me an
expression/code
to
link the validation to the SessionID in the main form?
This is probably very basic but I am new to Access.
 

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