By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,671 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,671 IT Pros & Developers. It's quick & easy.

Require field entry based on data entered in another field.

P: n/a
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/For...ccess/200801/1

Jan 29 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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!!
Jan 29 '08 #2

P: n/a
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
Jan 30 '08 #3

P: n/a
Create a Validation Rule on your table.

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

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" <u40941@uwewrote 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!!
Jan 30 '08 #4

P: n/a
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/For...ccess/200801/1

Jan 30 '08 #5

P: n/a
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/ValidationRul...ValidationRule

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/For...ccess/200801/1

Jan 30 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.