Require field entry based on data entered in another field.

Require field entry based on data entered in another field.

am 30.01.2008 00:12:57 von u40941

On a form, how do I require entry of a field based on the data in another
field? I do not want to require at the table level.

I have a field that the user selects where a refund goes. If they choose
"Other", field "Other Explanation" cannot be Null. If they choose
"Producer" then field "Producer Code" cannot be Null.

Your help would be greatly appreciated!!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-ac cess/200801/1

Re: Require field entry based on data entered in another field.

am 30.01.2008 00:40:54 von Salad

lsimonelli via AccessMonster.com wrote:
> On a form, how do I require entry of a field based on the data in another
> field? I do not want to require at the table level.
>
> I have a field that the user selects where a refund goes. If they choose
> "Other", field "Other Explanation" cannot be Null. If they choose
> "Producer" then field "Producer Code" cannot be Null.
>
> Your help would be greatly appreciated!!
>

Re: Require field entry based on data entered in another field.

am 30.01.2008 00:58:15 von Salad

lsimonelli via AccessMonster.com wrote:

> On a form, how do I require entry of a field based on the data in another
> field? I do not want to require at the table level.
>
> I have a field that the user selects where a refund goes. If they choose
> "Other", field "Other Explanation" cannot be Null. If they choose
> "Producer" then field "Producer Code" cannot be Null.
>
> Your help would be greatly appreciated!!
>
I created a table with 3 text fields; Code, Desc1, and Desc2. Here's
the code for the form. Sub LockFields permits mod of field based on code.

Private Sub Form_Current()
LockFields
End Sub
Private Sub Code_AfterUpdate()
LockFields
If Me.Code = 1 Then
Me.Desc1.SetFocus
Me.Desc2 = Null
Else
Me.Desc2.SetFocus
Me.Desc1 = Null
End If
End Sub
Private Sub Desc1_Exit(Cancel As Integer)
If Me.Code = 1 And IsNull(Me.Desc1) Then
MsgBox "Enter Description 1"
Cancel = True
End If
End Sub
Private Sub Desc2_Exit(Cancel As Integer)
If Me.Code = 2 And IsNull(Me.Desc2) Then
MsgBox "Enter Description 2"
Cancel = True
End If
End Sub
Private Sub LockFields()
Dim intCode As Integer
intCode = Nz(Me.Code, 0)
Me.Desc1.Locked = (intCode <> 1)
Me.Desc2.Locked = (intCode <> 2)
End Sub

Be young
http://www.youtube.com/watch?v=hiFOvrDAxxw

Re: Require field entry based on data entered in another field.

am 30.01.2008 11:42:31 von Allen Browne

Create a Validation Rule on your table.

For details, see the 2nd example in the 2nd section of this article:
http://allenbrowne.com/ValidationRule.html#TableValidationRu le

Be sure to bracket carefully if you are combining ANDs and ORs on multiple
pairs of fields.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"lsimonelli via AccessMonster.com" wrote in message
news:7ef46b00eff6a@uwe...
> On a form, how do I require entry of a field based on the data in another
> field? I do not want to require at the table level.
>
> I have a field that the user selects where a refund goes. If they choose
> "Other", field "Other Explanation" cannot be Null. If they choose
> "Producer" then field "Producer Code" cannot be Null.
>
> Your help would be greatly appreciated!!

Re: Require field entry based on data entered in another field.

am 30.01.2008 17:44:42 von u40941

Thank you so much for your prompt response. I will try this!

ps. I watched the video...good song. The video makes me wish I was in
Jamaica!!


>Be young
>http://www.youtube.com/watch?v=hiFOvrDAxxw

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-ac cess/200801/1

Re: Require field entry based on data entered in another field.

am 30.01.2008 17:45:52 von u40941

Thank you also for your prompt response. I am going to try both solutions
and see which works best.

Allen Browne wrote:
>Create a Validation Rule on your table.
>
>For details, see the 2nd example in the 2nd section of this article:
> http://allenbrowne.com/ValidationRule.html#TableValidationRu le
>
>Be sure to bracket carefully if you are combining ANDs and ORs on multiple
>pairs of fields.
>
>> On a form, how do I require entry of a field based on the data in another
>> field? I do not want to require at the table level.
>[quoted text clipped - 4 lines]
>>
>> Your help would be greatly appreciated!!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-ac cess/200801/1