Inputbox ok,cancel buttons

XaloRichie

Registered User.
Local time
Today, 11:13
Joined
Jul 2, 2003
Messages
70
I have a function which uses an input box to get a customer number and passes it to a query criteria.

The input box has OK and cancel buttons, which i have not defined. If the user click ok all is fine but the query displays blank if they click cancel. here is the code.


Dim MSG_BAR, titl_bar, Default_bar
MSG_BAR = "Please Scan or Enter Customer ID"
titl_bar = "Customer Selection"
Default_bar = "1"
LastCust = DLast("[CustomerID]", "CustomerDetails")
WantcusID = InputBox(MSG_BAR, titl_bar, Default_bar)

If WantcusID <= 0 Or WantcusID > LastCust Then
MsgBox "This is not a Valid Customer number please re enter"
GetCkCustid

What can i do to reset all if they press cancel?
 
Instead of using a message box, why not make a customised form that will allow you to control the data you get from the user.

i.e.

If you are expecting a text value then you can use the form's module to test for numeric values. You can ensure the user enters a value. Or if you are wanting them to enter a value that is probably listed in the database, you can use a combobox and allow them to select the data.

Using a form in lieu of the default Input Box opens up far more options for tightening up your application.
 
Because the input could be comming from a barcode scanner.

All I really want to know is how to check if cancell button is pressed and if so perform an action.
 
The answer for my case was simple : As if the user clicks cancel the input box value is null so;.

Where I check the return value of the function
I simply added
If {function name} is null DoCmd.Close which closed the form and reset everything nicely.
 

Users who are viewing this thread

Back
Top Bottom