-
March 10th, 2016, 08:38 PM
#1
validating textboxes before opening database
I need an advanced validation to validate entries in textboxes even before it opens the database to check entries or input in database
I am creating a database which should allow no empty names or not valid email addresses but my program validates alright but opens the database and inputs the wrong data even after collecting errors
Any help would be much appreciated
-
March 13th, 2016, 10:40 AM
#2
Re: validating textboxes before opening database
What have you done so far?
-
March 13th, 2016, 12:41 PM
#3
Re: validating textboxes before opening database
should i post the the whole code here pls ???
-
March 13th, 2016, 01:55 PM
#4
Re: validating textboxes before opening database
Whatever code or problem you are struggling with, please post it with proper explanation
-
March 14th, 2016, 11:09 AM
#5
Re: validating textboxes before opening database
Without seeing your validation code and the code that goes on to save the data there is no way to be sure exactly what you have done but it sounds like you are using some conditional checks to see if the data is empty and perhaps valid but then continue on to the save regardless of that result. One simple solution may be to use a flag [i.e. a boolean var at the top of the routine] make sure that it is false at the top of the routine then if any of the validation fails set the flag to true.
When you get to the code that would save the data wrap that in a conditional statement that checks the state of the flag and saves only if the flag is still false at that point.
Code:
dim Failed as Boolean
If Text1.Text=vbnullstring then
failed=true
'display message if desired
End If
If Text2.Text=vbnullstring then
failed=true
'display message if desired
End If
' continue with whatever validations are needed.
If Not Failed then
'save your data
End If
Now of course this assumes that all the validation and the save code are in the same routine. If they are in different routines then the boolean var needs to be defined at the top of the code for the form or in a module and if in a module may need to be public.
Also if the boolean is defined outside the routine then the first thing that needs to happen is to set the boolean to false before you begin the validations
Always use [code][/code] tags when posting code.
-
April 4th, 2016, 12:55 PM
#6
Re: validating textboxes before opening database
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|