Solved

Input box criteria

Posted on 2016-11-14
3
47 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
[X]
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
3 Comments
 
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"
    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 50

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

726 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