Solved

How can one force to add a value in a  inputbox on microsoft access 2013

Posted on 2014-02-12
3
749 Views
Last Modified: 2014-02-12
hi

i have a form in microsoft access that when i press on a button it's opening an iputbox that ask "what is the value ". and i want to force the user to put the value 1 or 2, and if he don't enter it this will show up an msgbox that he must to put a value between 1-2, and when he will press ok  the inpubx will show up again like an endless loop, and the user can stop it only when he press on the cancel on the inputbox button


dim a as long
a = clng(inpubox("press a value between 1-2")
if not a>0 or not a <3 then
msgbox "you must ot enter a value between 1-2
inputbox again

Open in new window

0
Comment
Question by:bill201
3 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 250 total points
ID: 39854513
Dim a As Long
Do
a = CLng(InputBox("press a value between 1-2"))
     If Not a > 0 Or Not a < 3 Then
          MsgBox "you must enter a value between 1-2"
          Else
          Exit Do
     End If
Loop
0
 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 250 total points
ID: 39854527
Although I generally frown on the use of inputbox, preferring forms for entering critical information like this, the only way to "force" a valid entry is to do it within a loop like Rey has recommended.

When I do this, I generally add a loop counter and after the user incorrectly enters a value 3 times, I present them with a different message and then force them out of the procedure that needed that value.
0
 

Author Closing Comment

by:bill201
ID: 39854583
thanks a lot
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 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

11 Experts available now in Live!

Get 1:1 Help Now