Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Form event to catch Issue

Posted on 2014-02-14
Medium Priority
Last Modified: 2014-02-14
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
Question by:Rayne
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 48

Expert Comment

by:Dale Fye
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.

Author Comment

ID: 39860559

Author Comment

ID: 39860563
Hello Dale,

I got error and on debug it gave me this….see attached
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

LVL 48

Accepted Solution

Dale Fye earned 2000 total points
ID: 39860698
Don't use the BeforeUpdate, use AfterUpdate

Author Comment

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

Expert Comment

by:Dale Fye
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.

Author Comment

ID: 39860764
yup yup it worked, thank you Dan

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

604 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