473,666 Members | 2,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check for NULL values on main form and sub-forms

69 New Member
Microsoft Access '97
Main Form and 3 subforms.
Code = VBA

Hi there am wondering how I would be able to do the following:

I need to ensure the end-user makes an entry in controls on both the main form and the sub-forms. Should I just set each field to REQUIRED = YES??

I would like to have a window pop up and indicate which fields are missing once they get to the last data entry control. Not sure which way to go with this.

Your help with this will be GREATLY appreciated.

Thank you,

K Escherich
Jun 23 '07 #1
2 5194
JConsulting
603 Recognized Expert Contributor
Microsoft Access '97
Main Form and 3 subforms.
Code = VBA

Hi there am wondering how I would be able to do the following:

I need to ensure the end-user makes an entry in controls on both the main form and the sub-forms. Should I just set each field to REQUIRED = YES??

I would like to have a window pop up and indicate which fields are missing once they get to the last data entry control. Not sure which way to go with this.

Your help with this will be GREATLY appreciated.

Thank you,

K Escherich

This bit of code will help you out. Put it in a code module and use it as described.
J
Expand|Select|Wrap|Line Numbers
  1. Function ValidateForm(strForm As String, Optional strSubform As String)
  2. 'This function Makes sure each field on a form is completed
  3. 'It is called this way from the form's before update event
  4. ' ValidateForm me.name  (if you're just doing the main form)
  5. ' ValidateForm me.name, me.subformname
  6.  
  7. Validate = False
  8. Dim F As Form
  9. Dim c As control
  10. Dim cName As String
  11. Dim strVal As String
  12. Set F = Forms(strForm)(strSubform).Form
  13. For Each c In F
  14.     If TypeOf c Is TextBox Or TypeOf c Is ComboBox Then  ' You can add additional types here
  15.         cName = c.Name
  16.         If Nz(c.Value, 0) = 0 Then
  17.             MsgBox "You must complete all fields"
  18.             F(cName).SetFocus
  19.             F(cName).BackColor = vbYellow
  20.             Validate = True
  21.             Exit Function
  22.         Else
  23.             F(cName).BackColor = vbWhite
  24.         End If
  25.     End If
  26. Next c
  27. End Function
  28.  
Jun 24 '07 #2
mberlack
1 New Member
The code above seems to be exactly what I'm looking for with my form and datasheet subform, but I'm not sure how to use it could someone breakdown the steps?
Jan 20 '15 #3

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

Similar topics

3
2334
by: Jack | last post by:
Hi, I have a form when loaded, retrieves record from an access table. Among other fields there is a check box called FinalUpdate. This is tied to a field in Access of type Yes/No. The form retieves the values perfectly. This form is being used to update the record in the table via a successconfirmation.asp. Now, when the checkbox is loaded as checked, then unchecking the checkbox reflects the change in query result in...
1
2023
by: Patrick Gunia | last post by:
Hi, i´m trying to build a xml - parser, which should simply list all used tokens an dattributes including their values. So far, so good, this works, but now i try to check for illegal phrases in the source document regarding starttags. here is my parser so far: tokenlibrary.cpp: #include <iostream> using namespace std;
7
29893
by: Tony Johnson | last post by:
Can you make a check box very big? It seems like when you drag it bigger the little check is still the same size. Thank you, *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
4
11032
by: Jared | last post by:
Radio Button or Check Box and Event Procedures I need to insert either radio buttons or check boxes onto my form. I'm not sure which to use, or if there are other options. I am using the buttons to: if one is clicked, its corresponding information will become available on another document, if it's not clicked no information will be provided. If multiple buttons are clicked their information will available on the same document. I'm not...
4
4059
by: welie | last post by:
I have a problem canceling a check box update when placing a check in it. Checkbox is not bound. Here is what happens. User clicks a check box. In the BeforeUpdate method of the control, if the check box is being checked, some validation is performed. If the validation fails, I set cancel to true, and the check box is not checked afterwards. This is fine.
1
1590
by: DaveC | last post by:
I have a simple one form VB.NET desktop app, that does a little threading like so mThread = New System.Threading.Thread(AddressOf DoSearch) mThread.Start() mThread has been decleared with the form class Dim mThread As System.Threading.Thread The DoSearch sub is in the same class as my form, and this sub is adding
3
8785
by: jsurkin | last post by:
I have a form that lists a single work request, with an attached continuous subform that lists specific items that are part of the request. Each item in the subform has a check box to indicate when the work is completed, along with a date text box to indicate when the work was completed. There is also a check box and corresponding date field in the main form to indicate when the entire request is completed. I'm trying to create an event...
10
9025
by: Toby Gallier | last post by:
Hello! I have a form that is calculating averages as follows: " =(NZ()+Nz()+Nz())/3 " However I need to now adjust for null values , so for example if value2 is null I would then need to base my average on just 2 values instead of 3 i am currently using in my string. How can i have the form update the "3" based on the number of values that are populated?
10
5009
Dököll
by: Dököll | last post by:
Me again! I have been battling this one for months. Wrote below to aid in getting certain subforms to hide once checkbox named Active is clicked. I am hoping to make the code work for Date fields that may be empty. I think i am going about it the wrong way: Private Sub Active_BeforeUpdate(Cancel As Integer) 'On current event of main form 'Check if checkbox is selected 'then show or hide subform
0
3063
prabirchoudhury
by: prabirchoudhury | last post by:
CRITERIA; +-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+ | CritCode | int(4) | NO | PRI | 0 | | | Description | varchar(150) | YES | | NULL | | | CritGroup | varchar(10) | YES | | NULL | | | Detail | varchar(30) | YES | | NULL | ...
0
8352
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
8863
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...
1
8549
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
8636
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
7378
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
6189
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
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.