Error checking between a check box and a text field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

On this form, there are a series of check boxes and text boxes that are
related to one another; for example, PlanA (check box) and PlanEnroll
(textbox). Sometimes, people enter a number in PlanEnroll without checking
the PlanA box. I would like to make it so that the users cannot continue to
the next record without checking that box.

If I can do this for the series of fields, I would greatly appreciate the
help.

Thanks,
Luther
 
Use the Before Update event of the form:

If Not IsNull(Me.PlanEnroll) and Not Me.PlanA Then
'There is an entry in PlanEnroll, but PlanA is not checked
MsgBox "PlanA is Not Checked"
Cancel = True
End If

Now, if you want it to be really user friendly (because if there are a
series of these), you can let them make a selection programmatically, get the
values correct and proceed without having to go back to the control and fix
it. The following code assumes the user can either undo the data in
PlanEnroll or check PlanA or cancel and go back to entering data.

If Not IsNull(Me.PlanEnroll) and Not Me.PlanA Then
'There is an entry in PlanEnroll, but PlanA is not checked
Select Case MsgBox("Select Yes to Check PlanA" & vbNewLine _
& "Select No to delete data in PlanEnroll" & vbNewLine _
& "Select Cancel to return to editing", vbQuestion +
vbYesNoCancel, _
& "Data in PlanEnroll without PlanA Checked")
Case vbYes
Me.PlanA = True
Case vbNo
Me.PlanEnroll.Undo
Case vbCancel
Cancel = True
End Select
End If
 
Luther

Not sure I understand...

Are you saying that if anything gets entered into the [PlanEnrol] textbox,
that [PlanA] checkbox should be checked? If you have such a tight coupling,
it sounds redundant to require both.

What am I missing?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Why not only ENABLE the textbox if the checkbox gets checked? Othervise it's
greyed-out (disabled).
 
Yes Jeff, That is what I'm saying. These fields are used for different
purposes, the check boxes are plan types and the text boxes are enrollment
numbers (some calculations on text boxes, etc...)

Jeff Boyce said:
Luther

Not sure I understand...

Are you saying that if anything gets entered into the [PlanEnrol] textbox,
that [PlanA] checkbox should be checked? If you have such a tight coupling,
it sounds redundant to require both.

What am I missing?

Regards

Jeff Boyce
Microsoft Office/Access MVP


Luther said:
Hi,

On this form, there are a series of check boxes and text boxes that are
related to one another; for example, PlanA (check box) and PlanEnroll
(textbox). Sometimes, people enter a number in PlanEnroll without checking
the PlanA box. I would like to make it so that the users cannot continue
to
the next record without checking that box.

If I can do this for the series of fields, I would greatly appreciate the
help.

Thanks,
Luther
 
So I'm still not clear on this... bear with me, please.

If there's a plan number, any plan number, in the text box, the [PlanA]
checkbox must be checked.

Or are you saying that specific plan numbers are tightly linked to specific
"plans"? (Without real data to see as an example, it's a little tougher to
visualize.)

I still wonder if it might be possible to save the extra work. As long as
each plan number is tightly linked to a specific plan type, requiring both
is redundant. For example, if plan number 1234 was ALWAYS a PlanA type,
store that information in your table of plans, as a PlanType. Then, when
someone entered (?do folks have to remember plan numbers, or could you use a
combo box to look them up?) 1234, your query could return "PlanA" as
associated with than plan number.

Or am I still confused?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Luther said:
Yes Jeff, That is what I'm saying. These fields are used for different
purposes, the check boxes are plan types and the text boxes are enrollment
numbers (some calculations on text boxes, etc...)

Jeff Boyce said:
Luther

Not sure I understand...

Are you saying that if anything gets entered into the [PlanEnrol]
textbox,
that [PlanA] checkbox should be checked? If you have such a tight
coupling,
it sounds redundant to require both.

What am I missing?

Regards

Jeff Boyce
Microsoft Office/Access MVP


Luther said:
Hi,

On this form, there are a series of check boxes and text boxes that are
related to one another; for example, PlanA (check box) and PlanEnroll
(textbox). Sometimes, people enter a number in PlanEnroll without
checking
the PlanA box. I would like to make it so that the users cannot
continue
to
the next record without checking that box.

If I can do this for the series of fields, I would greatly appreciate
the
help.

Thanks,
Luther
 
Hi,
I tried your solution and got an error; one thing I forgot to mention is
that PlanEnroll data type is a number (Hope this helps)
 
Sorry, Jeff. Let me try to explain this another way:

Text box PlanEnroll is used to enter any number ( that # corresponds to an
enrollment), then the plan type is checked; that plan type can be HMO, PPO,
etc...What some people are doing is:

- enter an enrollment number in PlanEnroll (ex. 54902718), and DON'T check
the plan type.


Jeff Boyce said:
So I'm still not clear on this... bear with me, please.

If there's a plan number, any plan number, in the text box, the [PlanA]
checkbox must be checked.

Or are you saying that specific plan numbers are tightly linked to specific
"plans"? (Without real data to see as an example, it's a little tougher to
visualize.)

I still wonder if it might be possible to save the extra work. As long as
each plan number is tightly linked to a specific plan type, requiring both
is redundant. For example, if plan number 1234 was ALWAYS a PlanA type,
store that information in your table of plans, as a PlanType. Then, when
someone entered (?do folks have to remember plan numbers, or could you use a
combo box to look them up?) 1234, your query could return "PlanA" as
associated with than plan number.

Or am I still confused?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Luther said:
Yes Jeff, That is what I'm saying. These fields are used for different
purposes, the check boxes are plan types and the text boxes are enrollment
numbers (some calculations on text boxes, etc...)

Jeff Boyce said:
Luther

Not sure I understand...

Are you saying that if anything gets entered into the [PlanEnrol]
textbox,
that [PlanA] checkbox should be checked? If you have such a tight
coupling,
it sounds redundant to require both.

What am I missing?

Regards

Jeff Boyce
Microsoft Office/Access MVP


Hi,

On this form, there are a series of check boxes and text boxes that are
related to one another; for example, PlanA (check box) and PlanEnroll
(textbox). Sometimes, people enter a number in PlanEnroll without
checking
the PlanA box. I would like to make it so that the users cannot
continue
to
the next record without checking that box.

If I can do this for the series of fields, I would greatly appreciate
the
help.

Thanks,
Luther
 
Luther

Then before you allow the form's information to be updated (the form's
BeforeUpdate event), you'll need to validate that all required things are
done. Create an event procedure in the form's BeforeUpdate event.

Regards

Jeff Boyce
Microsoft Office/Access MVP


Luther said:
Sorry, Jeff. Let me try to explain this another way:

Text box PlanEnroll is used to enter any number ( that # corresponds to an
enrollment), then the plan type is checked; that plan type can be HMO,
PPO,
etc...What some people are doing is:

- enter an enrollment number in PlanEnroll (ex. 54902718), and DON'T
check
the plan type.


Jeff Boyce said:
So I'm still not clear on this... bear with me, please.

If there's a plan number, any plan number, in the text box, the [PlanA]
checkbox must be checked.

Or are you saying that specific plan numbers are tightly linked to
specific
"plans"? (Without real data to see as an example, it's a little tougher
to
visualize.)

I still wonder if it might be possible to save the extra work. As long
as
each plan number is tightly linked to a specific plan type, requiring
both
is redundant. For example, if plan number 1234 was ALWAYS a PlanA type,
store that information in your table of plans, as a PlanType. Then, when
someone entered (?do folks have to remember plan numbers, or could you
use a
combo box to look them up?) 1234, your query could return "PlanA" as
associated with than plan number.

Or am I still confused?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Luther said:
Yes Jeff, That is what I'm saying. These fields are used for different
purposes, the check boxes are plan types and the text boxes are
enrollment
numbers (some calculations on text boxes, etc...)

:

Luther

Not sure I understand...

Are you saying that if anything gets entered into the [PlanEnrol]
textbox,
that [PlanA] checkbox should be checked? If you have such a tight
coupling,
it sounds redundant to require both.

What am I missing?

Regards

Jeff Boyce
Microsoft Office/Access MVP


Hi,

On this form, there are a series of check boxes and text boxes that
are
related to one another; for example, PlanA (check box) and
PlanEnroll
(textbox). Sometimes, people enter a number in PlanEnroll without
checking
the PlanA box. I would like to make it so that the users cannot
continue
to
the next record without checking that box.

If I can do this for the series of fields, I would greatly
appreciate
the
help.

Thanks,
Luther
 
The error is:

Compile error: Method or data member not found.

I used the first part of the code (just to test). It highlighted .PlanEnroll

If Not IsNull(Me.PlanEnroll) and Not Me.PlanA Then
'There is an entry in PlanEnroll, but PlanA is not checked
MsgBox "PlanA is Not Checked"
Cancel = True
End If
 
Back
Top