473,513 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ACCESS 2000 - bad input

When entering an account number I ant a message to appear if the account
number is not 10 digits. I have figured out how to get the message in a
macro BUT I dont want the user to be able to proceed to another field
until the account number is fixed. What do I have to add to the code?

Len([AccountNo])<>10
Preston Holod

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #1
8 1608
In the design view....look for the Before Update event...
there uyse your
If Len([AccountNo])<>10 then
msgbox "Bad user...stop it...do it again"
AccountNo = "" (assuming this is a text field)
AccountNo.setfocus (Puts them right back in it again)
end if

Something to consider....what if they decide...to heck with it...and want to
stop...
you might want to allow for a CANCEL

HTH
MAL.
"Pres Holod" <ho***@optonline.net> wrote in message
news:40**********************@news.newsgroups.ws.. .
When entering an account number I ant a message to appear if the account
number is not 10 digits. I have figured out how to get the message in a
macro BUT I dont want the user to be able to proceed to another field
until the account number is fixed. What do I have to add to the code?

Len([AccountNo])<>10
Preston Holod

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #2
Mal
I typed this in the Before Update in the Control AccountNo and after
typing in a 5 digit number the message "Bad user...stop it...do it
again" appeared. GREAT, RIGHT? After hitting OK, a RunTime error
2147352567 came up - The Macro or Function set to the Before Update
property for this field is preventing Microsoft Access from saving the
data in the field. When I hit OK, I am back in the ACCOUNTNO field.
Bit I'd prefer to get there without the RunTime Error. Any ideas?
Preston Holod

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
1. Set the text box's BeforeUpdate property to:
[Event Procedure]

2. Click the Build button (...) beside this.
Access opens the code window.

3. Enter:

Private Sub AccountNo_BeforeUpdate(Cancel As Integer)
If Len(Me.AccountNo) <> 10 Then
Cancel = true
MsgBox "Enter 10 digits, or press <Esc> to undo."
End If
End Sub

Setting Cancel to True stops the user from exiting the box.

BTW, if you need to store some accounts with leading zeros, AccountNo must
be a Text field (not a Number field) in your table.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Pres Holod" <ho***@optonline.net> wrote in message
news:40**********************@news.newsgroups.ws.. .
When entering an account number I ant a message to appear if the account
number is not 10 digits. I have figured out how to get the message in a
macro BUT I dont want the user to be able to proceed to another field
until the account number is fixed. What do I have to add to the code?

Len([AccountNo])<>10
Preston Holod

Nov 13 '05 #4
Alan: Thanks for your input

I used your code as discussed and it worked. HOwever, when the Message
appears when the account number does not equal 10 and I press OK, and
Access message appears stating The Value in the field vilates the
validation rule for the record or field.............etc". When I hit
OK, I am then sent back the the AccountNo field.

Preston Holod

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #5
The behavior you describe suggest that you are using both a Validation Rule
and also the BeforeUpdate event procedure. Try one or the other.

You won't be able to get out of the text box if the validation rule is not
met, and you won't be able to get out of the text box if the BeforeUpdate is
canceled. Either should do the job.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Pres Holod" <ho***@optonline.net> wrote in message
news:40**********************@news.newsgroups.ws.. .
Alan: Thanks for your input

I used your code as discussed and it worked. HOwever, when the Message
appears when the account number does not equal 10 and I press OK, and
Access message appears stating The Value in the field vilates the
validation rule for the record or field.............etc". When I hit
OK, I am then sent back the the AccountNo field.

Preston Holod

Nov 13 '05 #6
Unfortunately, there is no validation rule. Any other ideas?

Preston Holod

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #7
Set the Cancel argument to True before exiting to Cancel the Update and you
will avoid that message. Mal must have forgotten, or assumed you'd know to
do so.

Larry Linson
Microsoft Access MVP

"Pres Holod" <ho***@optonline.net> wrote in message
news:40**********************@news.newsgroups.ws.. .
Mal
I typed this in the Before Update in the Control AccountNo and after
typing in a 5 digit number the message "Bad user...stop it...do it
again" appeared. GREAT, RIGHT? After hitting OK, a RunTime error
2147352567 came up - The Macro or Function set to the Before Update
property for this field is preventing Microsoft Access from saving the
data in the field. When I hit OK, I am back in the ACCOUNTNO field.
Bit I'd prefer to get there without the RunTime Error. Any ideas?
Preston Holod

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #8
Neither code seems to work perfectly. I still get runtime errors with
Mals code and the validation error with Allens. Help!!!

Preston Holod

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7812
by: Jay | last post by:
I previously posted this question under Visual Basic newsgroup, but was advised to re-post here. I'm hoping someone can help me solve an issue I'm having with VB.Net and Access 2000. Here's...
1
4970
by: Jatin | last post by:
Hi, I have developed an application using VB 6 (SP 5), MS Access 2000 and Crystal Reports 9. I migrated from from access to SQl Server 2000. This wasn't a problem as i could import all the...
2
2543
by: Rick Caborn | last post by:
I am having a problem with an Access 2000 report getting data from SQL Server 2000. Here are the specifications for it: RecordSource: a stored procedure (tested via query analyzer and working...
6
10991
by: Jan Szymczuk | last post by:
I'm creating a database in Access 2000 in XP Pro (SP2), I have downloaded Allen Browne's pop up calender for use in my database, and imported the forms: frmCalender, frmExample and the Module...
1
2875
by: bonnie.tangyn | last post by:
Hello all I get Too few parameters expected 2 error and "The MS Jet Database engine cannot find the input table or query "myTempTablename". Make sure it exists and that its name is spelled...
1
4160
by: Child of His | last post by:
I have been through every trick I know, or has been suggested. I have a one to two million line fixed field database in text format. I want to bring it into Access 97. When I use the external...
13
13231
yolenman
by: yolenman | last post by:
Hello - This is my first posting to this group, so please bear with me. Also note, that while I'm intelligent, databases are not in my field of knowledge. I'm working with a small limousine...
7
5340
by: bhavin30 | last post by:
Is there a way to obtain user information (using LOGON_USER server variables) when you have set up the security to Anonymous Access? I have tried setting the security to both Anonymous + Window...
1
2798
by: saddist | last post by:
Hello, I've been working on access 2000 for few days. I made some forms with textfields where you can type date. Those textfields had input mask set for short date 99/99/0000. Now software have...
9
1972
by: Ron | last post by:
Hi All, I've recently installed a program written in Access 2000 on a laptop. The laptop had an existing Office 2000 Pro which of course included Access. But the program acts oddly (more oddly...
0
7257
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
7535
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...
1
7098
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...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5682
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,...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.