473,802 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Contingent Required Fields in a Form

4 New Member
I have certain fields that I need to be required based on a previous answer in a combo box. Here is an example:

If the user selects "deposit" from the combo box for "Reimburse By" then I need the "Bank Name" combo box, account number field and "account type" combo box to become required.

Is this possible and if so how do I do it. TIA
Jan 3 '07 #1
8 2815
NeoPa
32,579 Recognized Expert Moderator MVP
I believe it is possible.
However it's going to be very hard to help with so little information provided. Remember we only know what you tell us, and that, so far, is very little.
Please see (POSTING GUIDELINES: Please read carefully before posting to a forum) for help in formulating a question that will help us to help you.

MODERATOR.
Jan 3 '07 #2
umuckatie
4 New Member
I believe it is possible.
However it's going to be very hard to help with so little information provided. Remember we only know what you tell us, and that, so far, is very little.
Please see (POSTING GUIDELINES: Please read carefully before posting to a forum) for help in formulating a question that will help us to help you.

MODERATOR.
I'm using Access 2000 and have created a form for employees to use to submit expenses they incur. I have certain fields and columns that are required and other fields and columns that I need to be required if the employee selects "deposit" from the column. If the employee selects "check" from the column then those fields should not be required. If "deposit" is selected then I have one field and two columns that I would like to be required. The field label is "account number" and the column labels are "bank name" and "account type"

I hope that clarifies! Thanks for any help :)
Jan 3 '07 #3
ADezii
8,834 Recognized Expert Expert
I have certain fields that I need to be required based on a previous answer in a combo box. Here is an example:

If the user selects "deposit" from the combo box for "Reimburse By" then I need the "Bank Name" combo box, account number field and "account type" combo box to become required.

Is this possible and if so how do I do it. TIA
Here is generic code that will not allow you to Save a Record if Deposit is
selected in the Reimburse By Combo Box and there are no values in one
or more of the Bank Name, Account Number, or Account Type Fields,
essentially making them required. Hope this is what you are looking for. It
resides in the BeforeUpdate() Event of the Form where the Update can be
cancelled should one of this conditions exist:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. If Me![cboReimburseBy] = "Deposit" Then
  3.   If IsNull(Me![cboBankName]) Then
  4.     MsgBox "You must provide a Bank Name"
  5.     Me![cboBankName].SetFocus
  6.       Cancel = True
  7.         Exit Sub
  8.   End If
  9.   If IsNull(Me![txtAccountNo]) Then
  10.     MsgBox "You must provide an Account Number"
  11.     Me![txtAccountNo].SetFocus
  12.       Cancel = True
  13.         Exit Sub
  14.   End If
  15.   If IsNull(Me![cboAccountType]) Then
  16.     MsgBox "You must provide an Account Type"
  17.     Me![cboAccountType].SetFocus
  18.       Cancel = True
  19.         Exit Sub
  20.   End If
  21. Else
  22.   'Do whatever
  23. End If
  24. End Sub
Jan 3 '07 #4
umuckatie
4 New Member
Here is generic code that will not allow you to Save a Record if Deposit is
selected in the Reimburse By Combo Box and there are no values in one
or more of the Bank Name, Account Number, or Account Type Fields,
essentially making them required. Hope this is what you are looking for. It
resides in the BeforeUpdate() Event of the Form where the Update can be
cancelled should one of this conditions exist:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. If Me![cboReimburseBy] = "Deposit" Then
  3.   If IsNull(Me![cboBankName]) Then
  4.     MsgBox "You must provide a Bank Name"
  5.     Me![cboBankName].SetFocus
  6.       Cancel = True
  7.         Exit Sub
  8.   End If
  9.   If IsNull(Me![txtAccountNo]) Then
  10.     MsgBox "You must provide an Account Number"
  11.     Me![txtAccountNo].SetFocus
  12.       Cancel = True
  13.         Exit Sub
  14.   End If
  15.   If IsNull(Me![cboAccountType]) Then
  16.     MsgBox "You must provide an Account Type"
  17.     Me![cboAccountType].SetFocus
  18.       Cancel = True
  19.         Exit Sub
  20.   End If
  21. Else
  22.   'Do whatever
  23. End If
  24. End Sub
Thanks for your help but I still can't get it to work.

It tells me "run-time error 2465' Microsoft access cannot find the field 'cboReimburseBy ' referred to in your expression"

What am I doing wrong? Am I supposed to change something??
Jan 3 '07 #5
NeoPa
32,579 Recognized Expert Moderator MVP
I don't mean to speak for ADezii, but as a general rule you need to adapt any code for your own database.
Unless you ask your question very well (very few do :() then the expert won't know enough about your situation (particularly the names of your controls and fields etc) to put the right names in their offering. What you need to do is read the code and make changes where appropriate for your database.
If this is too complicated for you at this stage, then you could post the relevant details in your question and most experts will tailor it to fit.
HTH.
Jan 3 '07 #6
ADezii
8,834 Recognized Expert Expert
I don't mean to speak for ADezii, but as a general rule you need to adapt any code for your own database.
Unless you ask your question very well (very few do :() then the expert won't know enough about your situation (particularly the names of your controls and fields etc) to put the right names in their offering. What you need to do is read the code and make changes where appropriate for your database.
If this is too complicated for you at this stage, then you could post the relevant details in your question and most experts will tailor it to fit.
HTH.
Thanks for the assistance. Sometimes I'll make assumptions about substitutions, renaming, etc. when I really should not. I try to do the best
with the information provided. BTW, you guys do a fantastic job with this
Forum.
Jan 3 '07 #7
NeoPa
32,579 Recognized Expert Moderator MVP
Not a problem ADezii. And thanks for the comments.
I believe the best way to look after our members is to look after our experts.
We want as many members as possible, but the only way that will happen is if the experts keep things going. You experts are the valuable assets of the site. You can have a million members, but if you have no experts then you can bet there won't be a million members left tomorrow. Let me, or any of the other moderators, know if you have any problems (I don't expect you to have any - but if you do...).
Jan 3 '07 #8
umuckatie
4 New Member
Ok I tried to figure out what I needed to change and I couldn't do it. My drop down box is named "reimburse by" I tried putting a space in there and it still doesn't recognize it. I guess I still don't know what I'm doing wrong. What info do you need to help me? Thanks and sorry for being so clueless :(
Jan 4 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2560
by: Spanky | last post by:
I am looking for some help with the following. I have a form with many fields. I have a table in the form that I need to make all the fields within the table required. Basic validation, just need to make sure they are not blank. Here is the kicker.... I have a javascript that adds rows and fields whenever the user clicks a button for add rows. So, the user clicks button and I add a row with about 5 fields. Every time a user clicks...
14
2232
by: Oleg | last post by:
Hello there: I've been trying to create two different sets of required fields in one form and to use a radiobutton as sort of a switcher between these sets. In my HTML form there are two radiobuttons with values 'Via Email' and 'Printed Brochure'.
2
1867
by: Cliff R. | last post by:
Hello, I have a form that has a few required fields and also an "agree to terms" checkbox that must be required. I have used Javascripts for both functions individually, but I need a little help in combining them. Can someone help me combine these two scripts so they both work on the same page, with <FORM METHOD=POST onSubmit="return checkrequired(this)" etc., checking for required fields and making sure the agree-to-terms button is...
2
39119
by: bufbec1 | last post by:
I am pretty good with Access, but do not understand VBA. I have researched this topic and see only VBA answers, so I hope someone can help with my specific question. I have 2 fields for an end-user that must be filled in. I want an error message for each field. The forms are already partially filled in, and a user needs to select which record to go to. There are fields for them to fill in their initials and date , along with other...
3
2940
by: Orchid | last post by:
Hello All, Hope someone can help me on my required field problems. I have a form base on a table for users to input new Employees. There are 4 fields that cannot be Null when entering new records. (but on the table, I have these 4 field set up as "Required = No"). I want the codes to be able to check if the 4 fields are null, if is null, tell the user to input the null field(s), after the user input the required field, then ask if...
12
2367
by: dmieluk | last post by:
Problem: When moving between records, I need to control which combo/text boxes are displayed on the current form, dependent upon data in the current record. More: I building my first access database.
1
1949
by: swingingming | last post by:
Hi, I made a form based on one table that has several required fields. If in the form, I leave some of them blank and close the form using 'X', I get 2 warning messages, 1st is "... field is required." 2nd is "if you close, the data will be lost." How can I get rid of these or, if possible, I would like to replace them with my own. I tried Form Close event, doesn't work. Anyone could help me here? Thanks in advance. ming
7
3404
by: Tom van Stiphout | last post by:
I want to indicate requiredness by setting the background color of the control. Ideally I would call a sub in Form_Load to just do its thing. Below is what I have so far, but I realize this is of limited use because both Autonumber fields as well as Primary Key fields not necessarily have their Required property set, while they are required for the purpose of the Insert action. It seems to find out if a field is an Autonumber or PK...
1
3043
by: sdavis1970 | last post by:
I am working on an Access 2002 database where one of the tables has five required fields making up the key. There is a form that is linked to this table which is used for adding new records. There is a close button on this form that has the following code in it's OnClose event: "DoCmd.close"
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10536
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10304
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9114
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...

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.