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


Input box criteria

Posted on 2016-11-14
Medium Priority
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
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
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 52

Accepted Solution

Gustav Brock earned 2000 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

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.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

618 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