Solved

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

Posted on 2014-02-12
3
754 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

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

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

12 Experts available now in Live!

Get 1:1 Help Now