473,387 Members | 1,516 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,387 software developers and data experts.

How to get user to fill each field before going to the next

ql25
3
Dear Friends,

I am a kind of new to acess VBA, and I have an access form with muliple fields. What I want is to write an access VBA code that asks user to fill each field before going to the next field so if there is any empty field the user can not take any action.

Any help would be highly appritaited.
Jun 8 '10 #1
4 2000
missinglinq
3,532 Expert 2GB
This would require
  1. Setting all but the first control to Enabled = False
  2. After a given control is populated, in its OnExit or AfterUpdate event, enabling the next control
  3. Repeating this for all control
  4. Doing the above in the Form_Current event as well

This approach is really ill-advised for several reasons. If there are many 'fields' you're talking about a huge amount of work
  1. End users each have their own approach to data entry and it seldom coincides with the developer's idea of what should be entered in what order
  2. If they don't have a piece of data at hand, most prefer to complete the rest of the record, retrieve the missing data, then fill in that control
  3. What do you do if they fill in a field, move on, filling in other fields, then come back and delete the data a previous field?

Are you beginning to get an idea of what you're talking about?

Checking for Null (empty) controls is usually done in the Form_BeforeUpdate, just prior to committing the data to the underlying table. Here's a simple example for two fields. It could be expanded, of course, and even coded to step thru all controls without actually naming them explicitly:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.  If IsNull(Me.Control1) Then
  3.    MsgBox "Control1 Must Not Be Left Blank!"
  4.    Cancel = True
  5.    Control1.SetFocus
  6.    Exit Sub
  7.  End If
  8.  If IsNull(Me.Control2) Then
  9.    MsgBox "Control2 Must Not Be Left Blank!"
  10.    Cancel = True
  11.    Control2.SetFocus
  12.    Exit Sub
  13.  End If
  14. End Sub
Your thoughts?

Welcome to Bytes!

Linq ;0)>
Jun 8 '10 #2
NeoPa
32,556 Expert Mod 16PB
Another common approach is to set the ValidationRule property of the underlying table. While in Design View of the table use Alt-Enter (or View / Properties from the menu) to see all the properties of the table. The ValidationRule property can be used to check settings where multiple fields are involved, particularly where the values in one field effect the valid values of another.
Jun 8 '10 #3
ql25
3
Thnks guys for your replay but i am having truble with it , so would you please show me a way that i coulde loop all null fields in the current form showing a message that user should fil out each fields throught click button.

Your help is highly appritiated.
Jun 16 '10 #4
NeoPa
32,556 Expert Mod 16PB
That's not how it works I'm afraid. We answer questions where we can, but you do the work.

If you have a specific reason that you can't understand what we are saying then please explain this and we'll do what we can to help. Simply doing it for you is not an option. You need to give it a good attempt first and tell us where you struggle.
Jun 16 '10 #5

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

Similar topics

0
by: Don | last post by:
Hi, My database is composed of INNODB tables such as... CREATE TABLE user ( name VARCHAR(255) NOT NULL ) TYPE = INNODB;
1
by: allyn44 | last post by:
Hello, I have a table that has null fields that need to be filled in with the value of the previous record (example below) id date 1 2/2/02 2 3 4/4/02 4
1
by: RiesbeckP | last post by:
Hi All, I have a DB where there are customer numbers and a few other fields. I want to be able to pull all of the null records for a particular field as well as all the other customer numbers...
6
by: Tina | last post by:
in the itemDatabound event of a datagrid, both null fields and blank string come through as   in the e.items.cells field. Is there anyway to tell them apart? Thanks, T
1
by: Ranjan as usual | last post by:
Dear folks, I'm programming in VB .net and trying to import values from fields in a table in SQL. Everytime there is a NULL value in SQL, the program doesn't work and shows an error. How does VB...
0
by: ar | last post by:
I'm creating an XML web service using C# in .NET v1.1. Some fields that will be returned by the service contain NULL values. If the value is Null, I still need to preserve a XML tag for that field....
1
by: phillip.s.powell | last post by:
I'm having the most bizarre problem with PHP/MySQL that I've ever faced and it's an urgent matter (of course) to try to fix it ASAP. We have one record inserted into a table with 75 columns,...
2
by: foxylady | last post by:
Hi, everyone I have a issue I cant seem to figure out. I am trying to count how many fields are not NULL or empty. the form that I have that post this script has the field name n1,n2,n3 ect... ...
1
by: Neekos | last post by:
I have a report that shows information for up to 5 passengers per booking. Not every booking has all 5 passengers in it, so i dont want those fields showing up on my report. How can i get rid of...
2
AdminCyn
by: AdminCyn | last post by:
I am trying to create a report to simulate an invoice. I have created a Select query to join all the tables/fields into one. That is working all good. I have set the Format to be 0;0;0;0 so that if...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.