473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to Force an Input Value in a Query

132 100+
Hello All,

I've created a report that lists un-filled orders by age (in days). When the user clicks on the report it will ask them to input the number of days. (If the user wanted to see all un-filled orders over the last 30 days, they would input 30) However, If the user fails to enter a value, I get run-time error number 3071. My question is is there a way to FORCE the user to enter a value in order to prevent the run-time error?
Dec 4 '07 #1
5 2987
Dan2kx
365 100+
if they are entering the value into a form you could set an on exit command (from the textbox) in VB such as

If IsNull(Me!txtBoxInput) Then
msgbox "please enter a value"
docmd.cancelevent '- to set focus on the textbox again
else
exit sub
Dec 4 '07 #2
ADezii
8,834 Expert 8TB
Hello All,

I've created a report that lists un-filled orders by age (in days). When the user clicks on the report it will ask them to input the number of days. (If the user wanted to see all un-filled orders over the last 30 days, they would input 30) However, If the user fails to enter a value, I get run-time error number 3071. My question is is there a way to FORCE the user to enter a value in order to prevent the run-time error?
  1. Reports do not acknowledge the Click() Event.
  2. To force a User to enter a legitimate value for the Number of Days between 1 and 30, and to also allow him/her the option of selecting Cancel or OK with no value entered, try:
    Expand|Select|Wrap|Line Numbers
    1. Dim strNumOfDays As String, blnAcceptableValue As Boolean
    2. Dim intNumberOfDays As Integer
    3.  
    4. Do
    5.   strNumOfDays = InputBox$("Enter some value", "Enter Something or Other")
    6.   If strNumOfDays = "" Then Exit Sub
    7.     If IsNumeric(strNumOfDays) And Val(strNumOfDays) > 0 And Val(strNumOfDays) <= 30 Then
    8.       blnAcceptableValue = True
    9.         intNumberOfDays = Val(strNumOfDays)
    10.     Else
    11.       blnAcceptableValue = False
    12.     End If
    13. Loop Until blnAcceptableValue
    14.  
    15. 'Use intNumberOfDays for further processing
Dec 4 '07 #3
Proaccesspro
132 100+
  1. Reports do not acknowledge the Click() Event.
  2. To force a User to enter a legitimate value for the Number of Days between 1 and 30, and to also allow him/her the option of selecting Cancel or OK with no value entered, try:
    Expand|Select|Wrap|Line Numbers
    1. Dim strNumOfDays As String, blnAcceptableValue As Boolean
    2. Dim intNumberOfDays As Integer
    3.  
    4. Do
    5.   strNumOfDays = InputBox$("Enter some value", "Enter Something or Other")
    6.   If strNumOfDays = "" Then Exit Sub
    7.     If IsNumeric(strNumOfDays) And Val(strNumOfDays) > 0 And Val(strNumOfDays) <= 30 Then
    8.       blnAcceptableValue = True
    9.         intNumberOfDays = Val(strNumOfDays)
    10.     Else
    11.       blnAcceptableValue = False
    12.     End If
    13. Loop Until blnAcceptableValue
    14.  
    15. 'Use intNumberOfDays for further processing
Not sure where to put the code.....I am running a query to retrieve the data. In the date field I have this in the criteria line

>=DateAdd("d",-[Enter Age Of Appeal In Days],Date())

this forces the user to input a number ANY NUMBER.
Dec 4 '07 #4
ADezii
8,834 Expert 8TB
Not sure where to put the code.....I am running a query to retrieve the data. In the date field I have this in the criteria line

>=DateAdd("d",-[Enter Age Of Appeal In Days],Date())

this forces the user to input a number ANY NUMBER.
Sorry, misunderstood, but I'll have another look at it later.
Dec 4 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Change this line of code ...

>=DateAdd("d",-[Enter Age Of Appeal In Days],Date())

to

>=DateAdd("d",-nz([Enter Age Of Appeal In Days],0),Date())

This will default the number of days to 0 if the user doesn't enter any number. No records will be returned but no error will show.

You can change to 0 to any number (e.g.) 30 if you wish to have a default setting.
Dec 11 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: JSjones | last post by:
Hi all, I'm new to these boards and my javascript experience is fairly limited and basic so please bear with me. Anyway, on to the question and some background. I'm developing using ColdFusion...
9
by: nsj | last post by:
I am working with a web applicaction that accesses a SQL Server database. I need the value of the 'id' column of the last inserted row in the table 'PERSON'. The SQL statement for that purpose is:...
2
by: Faraz | last post by:
Hi, I am working with DOM and I need to do the following: <sequence> <element name="input1" type="string"/> <element name="input2" type="string"/> <element name="input3" type="string"/>...
6
by: CW | last post by:
I have written a chat console using DHTML/ASPX. One of the hidden frame continuously refreshes and writes any new messages to a conversation transcript frame. My problem is that I need to keep...
5
by: gimme_this_gimme_that | last post by:
I'd like to create my own version of google suggest GS. If you haven't seen GS check it out at : http://www.google.com/webhp?complete=1&hl=en I've reviewed several AJAX write-ups on the...
3
by: Captain Dondo | last post by:
First of all, thanks for the serialize pointer in an earlier thread. That looks like it's the ticket. Now, I have a style/php question. (I am a C hacker by background, and thus everything is a...
14
by: Frank Swarbrick | last post by:
A few weeks ago I had posed a question about how one my create a cursor for a query where the predicate condition is dynamic. Meaning that the query might want to have one of several possible...
5
by: Dave Rado | last post by:
Hi I have been the following code by Freefind to use on my search page: <form action="http://search.freefind.com/find.html" method="get" accept-charset="utf-8" target="_self"> <input...
1
by: printline | last post by:
Hello All I'm quite new to xml vs. PHP, so i hope someone can help with an issue i have been struggeling with. I have an html form, that when submitted, it should create an xml file, and save...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.