I am trying to alert a user , by using a message box, to state the various missing data.This works OK except when all data is entered as appropriate I still get the "Warning Message" for missing data! The program therefore does not progress!
As you will have spotted I have used script from other sources as I am not at a level to write my own - hence my inability to solve the problem.
Any help, or pointers, would be greatly appreciated.
13 1872
boliches, I'm not speaking for the rest of the Moderators/Experts in this Forum, but personally I will not attempt to decipher 200 lines of code unles it is properly Formatted and Tagged. If you can get the code in a more readable and tagged format, I will be more than happy to have a look at it.
boliches, I'm not speaking for the rest of the Moderators/Experts in this Forum, but personally I will not attempt to decipher 200 lines of code unles it is properly Formatted and Tagged. If you can get the code in a more readable and tagged format, I will be more than happy to have a look at it.
I dont fully understand what you want, but I have cut it down to a manageable size (I hope) -
blnError = False
-
-
strError = "Please complete the following:" & vbCrLf
-
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
strError = strError & "Vehicle Details" & vbCrLf
-
-
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
End If
-
If blnError = True Then
-
Cancel = True
-
MsgBox strError, vbOKOnly + vbCritical, "Stop!"
-
Exit Sub
-
End If
-
The problem is the MsgBox is still shown even when all relevant Text Boxes are filled
I dont fully understand what you want, but I have cut it down to a manageable size (I hope) -
blnError = False
-
-
strError = "Please complete the following:" & vbCrLf
-
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
strError = strError & "Vehicle Details" & vbCrLf
-
-
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
End If
-
If blnError = True Then
-
Cancel = True
-
MsgBox strError, vbOKOnly + vbCritical, "Stop!"
-
Exit Sub
-
End If
-
The problem is the MsgBox is still shown even when all relevant Text Boxes are filled
This is what I was referring to, I'll look at it as soon as I get a chance. NOTE: Is there any reason why the Validation is not done in the BeforeUpdate() Event of frmDeal?
I dont fully understand what you want, but I have cut it down to a manageable size (I hope) -
blnError = False
-
-
strError = "Please complete the following:" & vbCrLf
-
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
strError = strError & "Vehicle Details" & vbCrLf
-
-
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
End If
-
If blnError = True Then
-
Cancel = True
-
MsgBox strError, vbOKOnly + vbCritical, "Stop!"
-
Exit Sub
-
End If
-
The problem is the MsgBox is still shown even when all relevant Text Boxes are filled
It appears that with your current logic, blnError will never evaluate to False. In the If...End If Statements, it seems to me that the ElseIf Clauses (Not IsNull()) should set the value of blnError to False, and the code syntax can be shortened. A couple of examples will illlustrate my point: - If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
trError = strError & "Vehicle Details" & vbCrLf
-
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
End If
-
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
-
blnError = True
-
strError = strError & "Mileage" & vbCrLf
-
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
-
blnError = True
-
End If
try -
'It's either Not Null or Null
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
trError = strError & "Vehicle Details" & vbCrLf
-
Else
-
blnError = False
-
End If
-
-
'It's either Not Null or Null
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
-
blnError = True
-
strError = strError & "Mileage" & vbCrLf
-
Else
-
blnError = False
-
End If
-
It appears that with your current logic, blnError will never evaluate to False. In the If...End If Statements, it seems to me that the ElseIf Clauses (Not IsNull()) should set the value of blnError to False, and the code syntax can be shortened. A couple of examples will illlustrate my point: - If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
trError = strError & "Vehicle Details" & vbCrLf
-
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
End If
-
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
-
blnError = True
-
strError = strError & "Mileage" & vbCrLf
-
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
-
blnError = True
-
End If
try -
'It's either Not Null or Null
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
trError = strError & "Vehicle Details" & vbCrLf
-
Else
-
blnError = False
-
End If
-
-
'It's either Not Null or Null
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
-
blnError = True
-
strError = strError & "Mileage" & vbCrLf
-
Else
-
blnError = False
-
End If
-
Have tried your suggestion, but for some reason when a textbox is null "blnError" still shows "blnError = False" and not "blnError = True"! WHY?? Is it because at the very beginning of the code I have -
Dim blnError As String
-
blnError = False
-
I have concluded the script with: -
If blnError = True Then
-
Cancel = True
-
MsgBox strError, vbOKOnly + vbCritical, "Stop!"
-
Exit Sub
-
Else: GoTo Continue
-
End If
-
-
Would this be right? As I get the feeling this code is not as you guys would write it! (" Continue:" is where the concluding code is to complete the task)
Your help please as I am struggling with getting blnError to equal the correct action ie False when False and True when True.
I meant to ask how you "Formatted and Tagged" the script to make it easier to read, also what is the benefit of putting the script in the "Before Update" event procedure as against on a Command Button? Is it a speed related thing?
I meant to ask how you "Formatted and Tagged" the script to make it easier to read, also what is the benefit of putting the script in the "Before Update" event procedure as against on a Command Button? Is it a speed related thing?
Have tried your suggestion, but for some reason when a textbox is null "blnError" still shows "blnError = False" and not "blnError = True"! WHY?? Is it because at the very beginning of the code I have
- Dim blnError As String
-
blnError = False
- 'The correct Syntax should be:
-
Dim blnError As Boolean
-
blnError = False
I meant to ask how you "Formatted and Tagged" the script to make it easier to read, also what is the benefit of putting the script in the "Before Update" event procedure as against on a Command Button? Is it a speed related thing?
The BeforeUpdate() Event of the Form fires before the actual data present on the Form is Saved to the underlying Record Source and is the logical location for Validation Code. You 'Format' and 'Tag' code segments by the use of Indentations and the Code Tags present in Edit Mod (#). Select a specific code block, then click on the # sign and designate the code context as text, vb, sql, etc. http://www.thescripts.com/forum/faq...._read_and_post boliches, there appears to numerous problems with your code segment, too many for a back-and-forth conversation. If you like, you can send me the Database as an E-Mail Attachment and I'll have a good look at it when I get a chance. The only problem is that it will not be anytime soon and the code itself is not simply a couple of lines. Let me know what you would like to do.
Have amended the syntax, but still am failing to get the blnError = False to blnError = True when a text box is "Null". What am I doing wrong?
Thanks for the update on Formatting etc.
Regards
Have amended the syntax, but still am failing to get the blnError = False to blnError = True when a text box is "Null". What am I doing wrong?
Thanks for the update on Formatting etc.
Regards
Thanks for your interest in my problem, but the database is quite sizeable and may be difficult for me to get you to where the problem is within the project.
My main issue here is that I want to alert a user that info is missing from a form, and therfore (via a msgbox) inform that user which items are missing! Have I gone about it in totally the wrong way? If so could you please advise.
Many thanks. (Really appreciate your time!)
Thanks for your interest in my problem, but the database is quite sizeable and may be difficult for me to get you to where the problem is within the project.
My main issue here is that I want to alert a user that info is missing from a form, and therfore (via a msgbox) inform that user which items are missing! Have I gone about it in totally the wrong way? If so could you please advise.
Many thanks. (Really appreciate your time!)
My advice to you would be the following: - Place the code in the BeforeUpdate() Event of the Form.
- Change the Declaration of blnError as previously indicated.
- Evaluate each If...End If Statement in turn, and if the results are correct, move to the next If..End If (will illustrate shortly).
- This Method is time consuming but effective, and eventually should produce the desired results.
-
Private Sub Form_BeforeUpdate(Cancel As Integer)
-
Dim objPDF As New PDFClass
-
Dim IngResult As Long
-
Const PDFENGINE_PDF995 = 5
-
Dim stFaxNo As String
-
Dim rptFaxDeal As String
-
Dim strBroker As String
-
Dim strTable As String
-
Dim strError As String
-
Dim blnError As Boolean
-
strBroker = Forms!frmMainForm.Text265
-
strTable = "tblDeals" + strBroker
-
blnError = False
-
-
strError = "Please complete the following:" & vbCrLf
-
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
blnError = True
-
strError = strError & "Vehicle Details" & vbCrLf
-
Else
-
blnError = False
-
End If
-
-
'Avoid Errors, not interested in Saving - only Testing
-
Cancel = True
-
End Sub
-
- Enter a Value in [Forms]![frmDeal]![frmDealsSub].Form![Text62], blnError should return False, if it does add the next If...End If Statement and continue this pattern until all conditions have been tested.
I think I now know why this is failing! -
Dim blnError As Boolean
-
blnError = False
-
-
strError = "Please complete the following:" & vbCrLf
-
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text118]) Then
-
blnError = True
-
strError = strError & "No. of Owners" & vbCrLf
-
Else
-
blnError = False
-
End If
-
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Colour]) Then
-
blnError = True
-
strError = strError & "Vehicle Color" & vbCrLf
-
Else
-
blnError = False
-
End If
-
-
If blnError = True Then
-
MsgBox strError, vbOKOnly + vbCritical, "Stop!"
-
Exit Sub
-
Cancel = True
-
End If
-
End Sub
-
This code works fine when all data is missing! However I think the problem is that as the code unfolds the blnError will equal what ever the final textbox is! For example if the final textbox (in the above case "Colour") has text in it then blnError = False. If the initial textbox (Text118) is Null the blnError will need to be True to action the msgbox. It is being overriden by the next textbox.
Hope this makes sense, but is there a resolution? Would some sort of loop work?? Would not have a clue myself!
I think I may have it: -
Dim strError As String
-
Dim blnError As Boolean
-
-
blnError = False
-
-
strError = "Please complete the following:" & vbCrLf
-
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text118]) Then
-
blnError = True
-
strError = strError & "No of Owners" & vbCrLf
-
End If
-
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Colour]) Then
-
blnError = True
-
strError = strError & "Colour" & vbCrLf
-
End If
-
-
If blnError = False Then MsgBox "All Completed"
-
If blnError = True Then
-
MsgBox strError, vbOKOnly + vbCritical, "Stop!"
-
Exit Sub
-
End If
-
What do you think?
Really appreciate your help on this matter, youve been very helpful.
I think I now know why this is failing! -
Dim blnError As Boolean
-
blnError = False
-
-
strError = "Please complete the following:" & vbCrLf
-
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text118]) Then
-
blnError = True
-
strError = strError & "No. of Owners" & vbCrLf
-
Else
-
blnError = False
-
End If
-
-
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Colour]) Then
-
blnError = True
-
strError = strError & "Vehicle Color" & vbCrLf
-
Else
-
blnError = False
-
End If
-
-
If blnError = True Then
-
MsgBox strError, vbOKOnly + vbCritical, "Stop!"
-
Exit Sub
-
Cancel = True
-
End If
-
End Sub
-
This code works fine when all data is missing! However I think the problem is that as the code unfolds the blnError will equal what ever the final textbox is! For example if the final textbox (in the above case "Colour") has text in it then blnError = False. If the initial textbox (Text118) is Null the blnError will need to be True to action the msgbox. It is being overriden by the next textbox.
Hope this makes sense, but is there a resolution? Would some sort of loop work?? Would not have a clue myself!
You could greatly simplify your If...End If logic via: - See if data in a Field is missing, if it is display an appropriate Message Box, if not drop through to the next If...End If Statement.
- If the data was missing, set Focus to the Field with the missing data.
- If the data was missing, Exit the BeforeUpdate() Event..
- If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
-
Msgbox <missing data appropriate Message Box>
-
[Forms]![frmDeal]![frmDealsSub].Form![Text62].SetFocus
-
Exit Sub
-
End If
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Steven James Samuel Stapleton |
last post by:
Will calling ksort() on an array speed up it's access?
For example, I have the array $file_index, which is accessed by a key (the
entry id) and has two sub elements in a one dimensional array...
|
by: pilar |
last post by:
Hi All,
It is possible to restrict data entry for 2 fields at the same time?,
i know how this may sound for you, please don't insult me (just
kidding, this is a great newsgroup). In my first...
|
by: David C. Barber |
last post by:
upsized an MDB to ADP/SQL Server 2000 under Access 2000. All the DAO code
that I've changed to ADO code is working fine, HOWEVER the form Record
Source itself does not seem willing to return data....
|
by: Gary Shell |
last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
|
by: Martin |
last post by:
I hope not, but, I think the answer to this question is "it can't be done".
Northwind sample database. Orders form.
Go to a new record.
Select a customer in "Bill To:"
Don't enter any...
|
by: jhutchings |
last post by:
Hello all, I have a form I designed for data entry. However, when I set
the form properties to Data Entry mode, the form completely disappears
for Access 2000 users. All they see is a white blank...
|
by: Hamed |
last post by:
Hello
I have a Data Entry Form having some controls including a TextBox. When the
user types an entry, I query a table and if it was entered before, I ask the
user (using ShowModal method of a...
|
by: seltzer |
last post by:
I am using Access 2000 but I also have the 2003 version.
I am working on creating a data entry form in Access for a research study. Since there is a maximum of 255 fields per table in Access, I...
|
by: Peted |
last post by:
I have an amazing problem which i think i have no hope of solving
Im working with a c# dot net module that is hosted by and runs under a
delphi form envrioment. Dont ask me how this insanity has...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: 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...
|
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: 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: 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...
|
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...
| |