Input box criteria

Posted on 2016-11-14
Last Modified: 2016-11-15
Is there a way to make a user enter a value greater than 0 in an input box?  In other words, 1 or greater.
Question by:SteveL13
LVL 119

Expert Comment

by:Rey Obrero
ID: 41886624
you can check/verify if the value entered is not equal to 0

If InputBox("Enter Value") >= 1 Then
    msgbox "Good value"
    MsgBox "Please enter a value greater than 0"
End If

Expert Comment

ID: 41886643
if you extend Rey's code it will accommodate strings, nulls etc.
Sub test1()
If Val(Nz(InputBox("Enter Value"), 0)) > 0 Then
     MsgBox "Good value"
     MsgBox "Please enter a value greater than 0"
 End If
End Sub
LVL 49

Accepted Solution

Gustav Brock earned 500 total points
ID: 41886993
As the Inputbox always returns a string, so should Nz, thus it should rather be:

Sub test1()
    If Val(Nz(InputBox("Enter Value"))) > 0 Then
        MsgBox "Good value"
        MsgBox "Please enter a value greater than 0"
    End If
End Sub 

Open in new window


Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Like Function in Query Dramatically Increasing Run Time 13 32
Newbie needs help printing from a form. 10 21
MS Access Tables Linking 6 43
Query design issue 2 24
This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

863 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

28 Experts available now in Live!

Get 1:1 Help Now