I am Trying to validate information entered into 4 fields on a form. They can not be empty. If one of the fields is empty then the code should give a message athen stop. If all fields are valid then it should continue. I have listed the code below, can some give direction.
[code]
Private Sub GetProjid_Click()
If Forms![frm_proj log]![site id] = "" Then
MsgBox "You have not selected a Location. " & _
"Please Correct This error and resubmit.", vbOKOnly, "Validation Error"
DoCmd.GoToControl "Forms![frm_proj log]![site id]"
Cancel = 1
End If
If Forms![frm_proj log]![Project Title] = "" Then
MsgBox "You have entered a Project Title. " & _
"Please Correct This error and resubmit.", vbOKOnly, "Validation Error"
DoCmd.GoToControl "Forms![frm_proj log]![Project Title]"
Cancel = 1
End If
If Forms![frm_proj log]![Description] = "" Then
MsgBox "You have not entered a Project Description. " & _
"Please Correct This error and resubmit.", vbOKOnly, "Validation Error"
DoCmd.GoToControl "Forms![frm_proj log]![Description]"
Cancel = 1
End If
If Forms![frm_proj log]![Proj# Sponsor] = "" Then
MsgBox "You have not Entered a Project Sponsor. " & _
"Please Correct This error and resubmit.", vbOKOnly, "Validation Error"
DoCmd.GoToControl "Forms![frm_proj log]![Proj# Sponsor]"
Cancel = 1
End If
Forms![frm_proj log]![Project ID] = Forms![frm_proj log]![site id] & "-" & IIf(Forms![frm_proj log]!mth _
< 10, "0" & Forms![frm_proj log]!mth, Forms![frm_proj log]!mth) & IIf(Forms![frm_proj log]!day _
< 10, "0" & Forms![frm_proj log]!day, Forms![frm_proj log]!day) & Forms![frm_proj log]!year & "-" & IIf(Forms![frm_proj log]![Record # fixed] < 10, "0" & Forms![frm_proj log]![Record # fixed], Forms![frm_proj log]![Record # fixed])
Me!New = "no"
End Sub
[code]
Thanks
1 1953 I modified only the relevant (Validation) portion of the code segment which should go in the BeforeUpdate() Event of the Form: - Private Sub Form_BeforeUpdate(Cancel As Integer)
-
If IsNull(Me![site id]) Then
-
MsgBox "You have not selected a Location. " & _
-
"Please Correct This error and resubmit.", vbOKOnly, "Validation Error"
-
Me![site id].SetFocus
-
Cancel = True
-
ElseIf IsNull(Me![Project Title]) Then
-
MsgBox "You have entered a Project Title. " & _
-
"Please Correct This error and resubmit.", vbOKOnly, "Validation Error"
-
Me![Project Title].SetFocus
-
Cancel = True
-
ElseIf IsNull(Me![Description]) Then
-
MsgBox "You have not entered a Project Description. " & _
-
"Please Correct This error and resubmit.", vbOKOnly, "Validation Error"
-
Me![Description].SetFocus
-
Cancel = True
-
ElseIf IsNull(Me![Proj# Sponsor]) Then
-
MsgBox "You have not Entered a Project Sponsor. " & _
-
"Please Correct This error and resubmit.", vbOKOnly, "Validation Error"
-
Me![Proj# Sponsor].SetFocus
-
Cancel = True
-
End If
-
-
'Drop through and resume Normal processing/Updating here
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dnna |
last post by:
I have a table which is bound to an Internet Explorer XML
data island. I'm using ASP.NET's client-side validators
for an input field in the table. The problem is that if
the input fields are in...
|
by: Bill nguyen |
last post by:
I use the sub below to detect data entry error. The problem is that users
are still able to move out of the textbox AFTER the sub is run (and error
msg popped up) without having to correct the...
|
by: Niclas |
last post by:
Hi,
I need to validate some data before it is submitted preferably using any of
the validation controls in Visual Studion (2003), but the validation is
slightly complex and require converision...
|
by: Furty |
last post by:
Hi,
I'm looking for the best practice for creating a generic data validation
implementation for my data bound business objects. I currently have a
business object base class implementing the...
|
by: stathis gotsis |
last post by:
Hello everyone,
I am tying to come up with an elegant way to process some input data that
come from a form. When the user hits the 'Submit' button, i want the form to
appear again with the...
|
by: gurdz |
last post by:
Does anyone know how to perform data validation in C? I have searched
google for every possible result, and I either end up with data
validation for C++ or nothing at all. I have also searched...
|
by: peev2001 |
last post by:
Hi every body,
I have some basic queries regarding validation of data entered by different users:
I have a form from where the users are going to enter the data. I have tried to put some...
|
by: Joel Hedlund |
last post by:
Hi!
The question of type checking/enforcing has bothered me for a while, and
since this newsgroup has a wealth of competence subscribed to it, I
figured this would be a great way of learning...
|
by: Rami |
last post by:
I am using an XSD schema to validate an XML document. I want to
validate both XML structure and . When I try to validate the
document, the validation only checks for things like proper tags, and...
|
by: hippomedon |
last post by:
Hello everyone,
I'm looking for some advice on whether I should break the
normalization rule. Normally, I would not consider it, but this seems
to be a special case.
I have created an...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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: 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...
|
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: 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...
| |