473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Require field entry based on data entered in another field.

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
5 6732
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Megan | last post by:
Hi everybody- I have 2 tables, Hearings and Rulings. Both have primary keys called, CaseID, that are autonumbers. I don't want both tables to have the same autonumber. For example, if Hearings...
9
by: MLH | last post by:
I have a database (datatrek.mdb) with a table named DATA. The table has a date/time field with default value = Now(). It has 100 records in it entered over a 50-minute period. I would like the...
5
by: lottaviano | last post by:
I am using Access 2002 and have two tables (Main and Actions) linked (in Relationships) on one field "CAL_ID" (primary key in Main Table). Main Table is a list of equipment. Actions Table lists...
2
by: AA Arens | last post by:
Somebody willing to assist me in the following? I want to have values from one field copied to another field when I choose choose a item from a drop down menu. I have 2 forms: 1 Company...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
1
thewesties
by: thewesties | last post by:
Could somebody please help me before I dump a gallon of water on my pc! I am very happy to have come across this site on the internet. TheScripts has helped me through so many issues to this...
5
by: David Wright | last post by:
Hello Everyone I would be grateful if someone could help me with the automatic increment of a field on my subform called ‘Test_SrNo’. I am Using Microsoft Office 2000. The auto entry of the...
14
by: mjvm | last post by:
HI, I have had a search for the answer to this question, but I can't transfer what I am reading to my database. I don't know enough about the language required, but have been able to get my...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.