Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2009, 12:56 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Default Incorrect Field Length

Hi All
I am using the following code to get the user to input the correct field length.
[FONT='Calibri','sans-serif']If Len(Me.AnPostRef.Text) < 6 Or Len(Me.AnPostRef.Text) > 6 Then
MsgBox "A valid Reference Number Must Be SIX Characters ", vbCritical + vbOKOnly, "Helpdesk Ref Number"
[/FONT]
[FONT='Calibri','sans-serif']I am not able to return the user back to the same field I have used setfocus option and it causes issues and error msg[/FONT]
[FONT='Calibri','sans-serif'][/FONT]
[FONT='Calibri','sans-serif']Regards[/FONT]
__________________
Brendan Bartley
 
Old June 10th, 2009, 06:03 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

What error message?? it should be working ok...

and why did you len < 6 and len > 6 and not just try len <> 6???
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old June 11th, 2009, 01:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Have you tried something like

Code:
If Len(Me.AnPostRef) <> 6 Then
  MsgBox "A valid reference number must be SIX characters!",  vbCritical, "Helpdesk Ref Number"
  Me.AnPostRef.Undo
End If
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
 
Old June 15th, 2009, 01:36 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Is this a bound text box? If so, you can set up this validation at the table level and not have to worry about creating this sort of coding on all your bound forms.
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
write text file with fixed field length hugoscp Classic ASP Professional 0 June 27th, 2007 06:12 AM
Help me on Fixed Field Length data files hossrad SQL Server DTS 3 January 29th, 2005 07:50 PM
SQL Server, field length of 20000 itHighway Classic ASP Databases 3 December 27th, 2004 01:16 AM
Determining the length of a database field john_reeve41 BOOK: Beginning ASP 3.0 2 February 26th, 2004 12:49 PM
Finding Field Type & string length From dataset? Jackie VB.NET 2002/2003 Basics 4 July 9th, 2003 04:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.