473,508 Members | 2,133 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 5187
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
2324
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...
1
2007
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...
7
29846
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 ***...
4
11022
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...
4
4048
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...
1
1585
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...
3
8763
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...
10
8997
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...
10
4978
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...
0
3047
prabirchoudhury
by: prabirchoudhury | last post by:
CRITERIA; +-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+...
0
7124
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
7326
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
7498
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...
0
5629
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,...
1
5053
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...
0
4707
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...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
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...

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.