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

Access Form and Character Limit

Microsoft Access 2003
Windows XP

I need a way to create a code for a form that if the text that is entered does not contain 7 characters, then the user will get an error message and the text field will clear.

Here is the code I have as of now:

Expand|Select|Wrap|Line Numbers
  1. Private Sub sampleno_BeforeUpdate(cancel As Integer
  2.  
  3. Private Sub sampleno_BeforeUpdate(cancel As Integer)
  4.  
  5. Dim sampleno As String
  6.  
  7. If Not sampleno Like "???????" Then
  8.  
  9. Me.Undo
  10.  
  11. MsgBox "Warning Sample Number " _
  12.         & sampleno & " was not the required length.", _
  13.         vbInformation, "InvalidInformation"
  14.  
  15. End If
  16.  
  17. End sub
Any help with this issue will be graetly appreciated.
Sep 14 '07 #1
2 2355
MindBender77
234 100+
Does this have to be written in code? You could create a custom input mask on the text box which uses 7 characters. Any more or any less will prompt with an error.
Sep 14 '07 #2
Scott Price
1,384 Expert 1GB
Explore the Len() function... It returns the length of a string, usable in vba code.

Regards,
Scott
Sep 14 '07 #3

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

Similar topics

8
by: Franck | last post by:
Hi, I'm having problems with css2/xhtml based form. I didn't find examples to see what can be done, especially textarea. How to define cols="45" rows="4" in css?
7
by: RCS | last post by:
Okay, a rather 'interesting' situation has arisen at a place I work: I need to convert a database from Access to something that can be used over the web. I am currently maintaining and...
5
by: Scott | last post by:
I have a customer that had developed an Access97 application to track their business information. The application grew significantly and they used the Upsizing Wizard to move the tables to SQL...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
2
by: Kevin | last post by:
I'm thinking of moving data from Excel to Access to get around Excel's 1024-character limit on text-wrapping, and just learned that unless you do something with VB, text field-type in Access 2003...
1
by: cefrancke | last post by:
I have a Back End database (split) that is on a smokin' hot machine (dual processor, 2 gig RAM, XP Pro SP2) and I'm getting an error that says the database (back end file) is "opened exclusively"...
1
by: Muchach | last post by:
Hello, Ok so what I've got going on is a form that is populated by pulling info from database then using php do{} to create elements in form. I have a text box in each table row for the user to...
1
by: circleandy | last post by:
I want to build a web form that has text areas with max character limits, and ensure that the text generated from the form will fit within allotted spaces in an InDesign Print Template. The text...
8
by: Theadmin77 | last post by:
Ok ,i have to create a page to allow entry of user information;all fields must be validated and error displayed otherwise * First Name (limit 25 characters) * Last Name (limit 25...
2
by: jthep | last post by:
I'm trying to get this piece of code I converted from C to work in C++ but I'm getting an access violation error. Problem occurs at line 61. Someone can help me with this? The function...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
marktang
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,...
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...
0
agi2029
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 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.