Solved

Input box criteria

Posted on 2016-11-14
3
19 Views
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.
0
Comment
Question by:SteveL13
3 Comments
 
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"
    else
    MsgBox "Please enter a value greater than 0"
 
End If
0
 
LVL 7

Expert Comment

by:COACHMAN99
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"
     Else
     MsgBox "Please enter a value greater than 0"
 End If
End Sub
0
 
LVL 49

Accepted Solution

by:
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"
    Else
        MsgBox "Please enter a value greater than 0"
    End If
End Sub 

Open in new window

/gustav
0

Featured Post

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.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…

760 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

19 Experts available now in Live!

Get 1:1 Help Now