Solved

Form event to catch Issue

Posted on 2014-02-14
7
314 Views
Last Modified: 2014-02-14
Hello,
An item number is always 7 digits. So if my item is 456, by format is should be 0000456. Now there is a access form where users will be entering the number for new items – how do I build the form so that it check for the correct data entry – or if the users enter 456, the form converts that entry to add 4 extra zeroes in front of the that number and then stores it in the table?  Any ideas

Thank you
0
Comment
Question by:Rayne
  • 4
  • 3
7 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39860536
You could use the AfterUpdate, LostFocus, or Exit event of the control, something like:

Private Sub txt_ItemNumber_AfterUpdate

    me.txt_ItemNumber = Right("0000000" & txt_ItemNumber, 7)

End Sub

This would add 7 zeros to the left of the ItemNumber and then take the right most 7 characters.  Make sure your ItemNumber field is formatted as text, because if it is numeric, the leading zeros will be dropped.
0
 

Author Comment

by:Rayne
ID: 39860559
0
 

Author Comment

by:Rayne
ID: 39860563
Hello Dale,

I got error and on debug it gave me this….see attached
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 39860698
Don't use the BeforeUpdate, use AfterUpdate
0
 

Author Comment

by:Rayne
ID: 39860725
I did used it, its not adding in the zeroes before and storing the way the number is typed in
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39860762
Did you use the Form_Afterupdate or the control afterupdate.  If you used the control afterupdate, it should save it properly when you save the form.
0
 

Author Comment

by:Rayne
ID: 39860764
yup yup it worked, thank you Dan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
My experience with Windows 10 over a one year period and suggestions for smooth operation
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now