Validating Data On Exit
Sep 10, 2006
I'm trying to figure out how to validate a field to make sure the users are not entering any blank spaces into the field. I've tried setting the mask up as "aaaaaa" but it still lets the user enter a blank space.
I've also tried building an event procedure to run on exit that reads:
Private Sub Barcode_Exit(Cancel As Integer)
Dim LPos As Integer
Dim LChar As String
Dim LValid_Values As String
'Start at first character in Barcode
LPos = 1
'Set up values that are considered to be alphanumeric
LValid_Values = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX YZ+-.0123456789"
'Test each character in Barcode
While LPos <= Len(pValue)
'Single character in Barcode
LChar = Mid(pValue, LPos, 1)
'If character is not alphanumeric, return FALSE
If InStr(LValid_Values, LChar) = 0 Then
AlphaNumeric = False
Exit Function
End If
'Increment counter
LPos = LPos + 1
Wend
'Value is alphanumeric, return TRUE
AlphaNumeric = True
If AlphaNumberic = False Then
MsgBox "Barcode cannot contain blank spaces, only letters and numbers.", vbExclamation, "Barcode Field Value"
Else
End Sub
****
However the message box does not come up and the form will not then let you get out of that field.
Any ideas? I've been checking on this field by running a query and then manually correcting the errors but I would rather that the DB check and force correction at the time the data is entered.
Any and all help will be greatly appreciated.
Charis
View Replies
ADVERTISEMENT
May 10, 2005
I have taken over a database that has be modified by a number of people over time. I have a forw with tab controls and a some of the fields are critical to be completed before you should be able to progress to the next tab. There are currently validation controls on the controls on the first tab, but if you only complete the first of these controls it is possible to move on to the second tab. The third tab is a subform and and if you try and select this tab, the validation text appears, but you can still switch to that tab which I want to prevent.
Finally, I have deleted one of the controls which was a critical field for completeion. I had assumed the validation was based on the validation on the control and would therefore be deleted but I still get a message saying complete this. I can't work out where there miight be code to make this happen? I'm not sure if anyone can help me with this without seeing the database, but I just wondered if anyone had any ideas what to even look for to help me understand this.
Sorry if all this is a bit vague, but would really grateful if anyone can help me at all.
View 1 Replies
View Related
Aug 12, 2007
Dear experts,
I'm quite new to Access but find it very interesting to learn more. I used to create data entry in other softwares but now like to use Acesss instead since it has many advantages i.e can be used for web survey.
My question is how to create the routing/ jump & how to check the relationship across fields for the same record right from the entry (i.e Age=18 ---> jump to "smoking"; "drinking"=yes --> "Age">25)
Any advice is really appreciated.
Thank you so much,:)
Hop
View 7 Replies
View Related
Apr 4, 2005
I have a form that asks 2 questions. Date and Account. I need to check a table to see if the combination of both date and account have not been used. Date is normally today, can be yesterday. Account has a drop down menu with 6 choices. If both the date and account have been used then there should be an error shown to that effect. If not used, then proceed on to the next form for data entry.
Can this be done? And how?
View 1 Replies
View Related
Jan 26, 2005
HI
How can exit from an "DataEntry=True" and "AllowAdditions=True" Form without add a new record to the table ??
Any help please!!!!!
Thanks
Ps: i only can do that if i press 'esc' in the 'textbox', but that doesn't suits me. the form only have a 'textbox' and a 'commandbutton'
View 2 Replies
View Related
Jul 19, 2007
I am developing an Access 2003 database for our shipping dept.
I have linked tables from a Sql Server 2000 Database that MakeTable queries were used to make tables then changed to Update Queries for the data.
The shipper opens a form (Call it Dock 1, Dock 2 , etc.) to scan a barcode or manually key the Batch Code in a ComboBox that is a lookup. "Enter" moves the cursor to create the next Record with the balance of the data pulled into the next 6 or 7 fields through VB Code. This data is written to a table for verification of each shipment.
My problem is that if the form is closed or the user exits Access, this form is empty when reopened but the table is intact. I need to be able to assure the form is not cleared on exit unless by request.
I have tried
"Private Sub Form_Open(Cancel As Integer)"
"docmd.gotorecord ,, aclast "
"End Sub"
in the Form, (Without the Quotes) nothing happened not data was returned but, the data was in the Table
I need all entries to be retained not just the last record
I am not a programmer but i have experience with VB6 and Access 2.0, 3.0, 97, 2002, & 2003. Any help will be appreciated and I offer my thanks in advance to all responders
View 2 Replies
View Related
May 3, 2006
I have a form that creates quotes for my company by inputting inventory items in a continuous subform. I need to be able to check and see if the item already exists in the inventory or if it is a new one that has been manually entered, and have this toggle a bound yes/no field that I will use to control whether or not some fields on the form are locked. Here is the code I have been using, but it doesn't seem to work at all.
Private Sub Combo14_AfterUpdate()
Dim itemcheck As Integer
itemcheck = DCount("[Item]", "tbItems", "[Item] = " & Chr(34) & Me![Item] & Chr(34))
If itemcheck = "0" Then
Me![Locked] = False
Else
Me![Locked] = True
End If
End Sub
I would appreciate anyone's feedback on this.
View 2 Replies
View Related
Jul 19, 2007
All I really need some help.
I have two tables:
Table 1
Table 2
There is a one to many relationship here.
One in table 1 and many in table 2.
When I add in a record in table 1, I need a validation script/key that won't allow adding a record to table 1 without a corresponding record in table two.
Please help. I'm really stuck. I am doing this through a form. I tried messing around with the "requirements" but had no luck.
View 5 Replies
View Related
Apr 2, 2008
I need to validate a surname field which obviously can only consist of letters and occasionally spaces and/or hyphens. (i.e. van Driel or Johnson-Crooks)I managed to create a validation rule which would allow me to have space in the surname field:Is Null Or Not Like "*[!((a-z) or ( ))]*"but when I tried to allow hyphens into the field - I used these codes - but none of them worked:Is Null Or Not Like "*[!((a-z) or ( ) or (-))]*"Is Null Or Not Like "*[!(a-z)]*" Or Not Like (" ") Or Not Like ("-")Is Null Or Not Like "*[!(a-z)]*" Or Not Like "*[!( )]*" Or Not Like "*[!(-)]*"Is Null Or Not Like "*[!(a-z)]*" Or Like "*[!( )]*" Or Like "*[!(-)]*"Is Null Or Not Like "*[!(a-z)]*" Or Not Like "*[( )]*" Or Not Like "*[(-)]*"Is Null or Not Like "*[!(a-z)]*" or (in ("-"," "))Is Null Or Not Like "*[!(a-z)]*" And (Not In ("*[0-9]*"))Is Null Or Not Like "*[!(a-z)]*" And (Not In ("*[0-9]*")) And (In ("-"," "))Is Null Or Not Like "*[!(a-z)]*" Or Like ( ) Or (-)Please can smeone help me.James
View 3 Replies
View Related
Nov 15, 2006
Hello all.
I'm having a problem with a query. I am pulling information from a table that holds demographic info plus some company info. the data in question is the deptno of an employee. This employee also has a jobcode associated with it. I have another table with a list of a few jobcodes.
The data I will retrieve is fname, lname and deptno. If a person is in detno 210 then I want to check his jobcode in the jobcode table. If it is in the table then I want it to return 215 for a deptno. If not then it will return 210.
Does anyone know how this query would look like?
Thanks in advance.
View 1 Replies
View Related
Oct 25, 2005
Question I am looking at some annoying Access database for a charity and got stuck on trying to make something work that they believe used to
Two Tables
Venues
pK Venue ID
Venue Name
Venue Capacity
Booking
pK
Venue
Name
Addr1
Addr2
Addr3
Ect
They have a query call capacity check which does the following
Count Occurrences of Venues then takes this away from venue capacity
Essentially they have a standard access form of the Booking table with a drop down box and want it to only validate if seats are still free at a venue eg if the current count for venue is less than the venue capacity.
Any ideas ?
View 2 Replies
View Related
Mar 23, 2006
Hi all
Im currently trying to set validation rules for a form using VBA, does anyone know of a good method of doing this as i'm a bit stuck:confused:
View 1 Replies
View Related
May 4, 2006
I have a NEW INVOICE button, and the code behind says
DoCmd.GoToRecord , , acNewRec
Now if a user clicks on this buttons 3 times, three blank records get inserted in the table. THis is because I am generating teh invoice number myself, and the invoice_date is defaulted to current date (DATE())
The script written in the Sub Form_BeforeUpdate event to validate if the invoice is empty, if the total is ZERO etc. is all skipped, and I get blank records in the table. I even tried to place breakpoints in the before updates script, but it does not even come inside.
What is the right way to trap data errors, blank records in this situation?
Please help.
Thanks,
Vinai
View 3 Replies
View Related
Jul 26, 2006
Hey,
I've been looking at this website (http://learning.north.londonmet.ac.uk/ib212/week7/validation.htm) and i'm trying to find an input mask that lets a user enter in an I.P. address like the IP settings in Network Connection > Properties > TCP/IP > Properties.
E.g. a user enters 19216802. I want this converted to 192.168.0.2 without the user having to enter any '.'
So far this is the closest i've gotten to validating the field
0##.0##.0##.0## whereas 0 means something has to be entered and the # are optional.
Thanks,
Barret
View 3 Replies
View Related
Jul 28, 2006
Hey,
In a form I am trying to complete, I want the user to be able to enter in an IP address like so
192168<user hits space bar>0<user hits space bar>1
Would convert to - 192.168.0.1
Is there an input mask which allows this to happen?
Thanks.
View 2 Replies
View Related
Jun 6, 2005
Does anyone know the code to exit from THE whole ACCESS program.
That is when I click the close button on the switchoboard, I want the system to close the whole of access program.
View 3 Replies
View Related
Nov 14, 2006
If my user uses the MS Access 'X' button (upper right hand of screen) to Exit the application does anyone know what methods are triggered that may let me perform some task before the application actually ends?
Thanks
View 1 Replies
View Related
Nov 29, 2006
HiBeen trying To Find A Way Of Validating A Postcode.But Getting No Where Being They Can Be Like CT1 1QX, CT11 2DT, CT11 12DT Act.Best I've done is to make sure there's a space and it starts and ends with a Letter.Any Help Advice Would be much AppreciatedMick
View 2 Replies
View Related
Jun 20, 2007
Hi there, just a quick question really.
I have got a start date and an end date field in a table both in Date/Time data type. Can i validate the end date so that it cannot be longer than 5 days after the start date, that has been entered. Or is this impossible to do in a table?
Thanks for any help
View 10 Replies
View Related
Mar 25, 2008
Hi
I have a large file where I am trying to clean up the data.
One of the fields is the email address.
I want to check if the email address has something followed by an @ symbol followed by something else. If it does not, then I want to replace it with a null value.
Can you help?
I thought that I could use the wildcard features such as <>*@* but this does not appear to be working.
Noel
View 6 Replies
View Related
Mar 25, 2008
Hi
I am trying to work with a large table of customer data.
I know that there is a large number of invalid values.
I would like to run a make table query that would check the phone number against a table of known invalid numbers (e.g. 1234567, 11111111, 99999999, etc).
If the number exists on the invalid table, then I would like to replace it with a null value.
Regards
Noel
View 1 Replies
View Related
Oct 27, 2004
I have two tables in an Access Database- One is the chart of accounts, and the other is the actual entries, with the common field being ID. Chart of accounts is set up something like this-
ID Description
1000 Customer Revenue
2000 Office Expenses
2100 Paper
That kind of thing. Anyway, I want to set up the ID field in the entries table so that it is basically a pull down box that only allows you to enter one of the IDs listed in the Chart of Accounts. Any way to do this? I'd really hate to have to write a quick separate program to do this.
View 6 Replies
View Related
Mar 12, 2005
Here is the code I have in a module. When I put the correct dates in, the message box appears telling me that the date is incorrect, but I have checked and the closing date appears to be later that the date for completion.
When I accept the error message I get a runtime error 2115 saying that the database engine is being prevented form saving the data to the table.
Can anyone offer some help as to my problem here?
The code:
Private Sub txtbx_Date_Closed_BeforeUpdate(Cancel As Integer)
'Declaring the variables
Dim Completed As String
Dim Closed As String
'Assigning values to the variables
Completed = "txtbx_Date_Completed"
Closed = "txtbx_Date Closed"
'Checking to see if there is no completed date
If IsNull(Completed) Then
MsgBox "The action must be completed prior to being closed"
Me![txtbx_Date_Closed] = Null
Exit Sub
'Validating the closing date
ElseIf Closed < Completed Then
MsgBox "The closing date cannot be before completion date"
Me![txtbx_Date Closed] = Null
Exit Sub
End If
End Sub
View 3 Replies
View Related
Oct 15, 2006
How can I check if the user is entering numeric values?
I can do it in the code, i.e. the lost focus event to the text box but I want to make a check in the "validation rule property" of the text box...!! How is it possible??
Thanks
View 1 Replies
View Related
Oct 16, 2006
How do I validate if the inputted value by the user is a decimal value or not?
Also I need that before the decimal only 3 digits should be inputted.
View 1 Replies
View Related
Oct 9, 2013
I am trying to validate two fields in a form against each other. Neither are required, but If one is filled in, then the other must be filled in. If neither is filled in then they can both be blank. It is for a time, and description related to that time.
So if they enter in 5 hours, they have to type in the description field describing those 5 hours. If they type in the description field, they have to type in the hours. Vice versa. Or they can both be blank.
Right now I put in the table properties validation rule
([Other Description In] Is Null) Or ([Other Time In]>0)
This works half way. It stops them from putting in a description without time. but they can still put time without a description.
I can't figure out how to do multiple validations of the same two fields. If I do an And or another Or statement it breaks the whole thing and they can enter with no restrictions.
Also, I tired to do it at form level for the other half (to stop them from putting time without a description) but it brings up a pop up and they cant tab to the description field to enter a description without putting time back to "0" first.
View 5 Replies
View Related