Solved

vbOK

Posted on 1998-10-14
6
385 Views
Last Modified: 2010-05-18
Hi,

I have a Inputbox.
I only want to use the OK button not the Cancel button.
Can I do this?
How do I do?
0
Comment
Question by:helenag
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:Helicopter
ID: 1965338
You can't do this with a standard input box. You need to write your own (it's only a form with a text box and a couple of buttons after all)
0
 

Author Comment

by:helenag
ID: 1965339
OK.
0
 

Author Comment

by:helenag
ID: 1965340
If I want to do something like this, how do I do?
How do I code the VbCancel button?

If vbCancel= true then
strInput=strDefault
End if

?????
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 8

Expert Comment

by:Helicopter
ID: 1965341
Is this with the standard input box:

You need to return a value so call the inputbox function like:

Public Function testinput()
Dim x As String

x=InputBox ("do something")


End Function

If you press the cancel x will equal "" (unfortunately it also equals "" if you press OK with no text in the box)

So you could test for it by if x="" then strInput=strDefault.

(by the way are you using the default property of the input box, as in x = InputBox("do something", "prompt", "mydefault") If you use this then pressing OK returns the default message whereas cancel returns the empty string. Just a thought.



0
 

Author Comment

by:helenag
ID: 1965342
Ok,Thanks.
0
 
LVL 3

Accepted Solution

by:
tcurtin earned 10 total points
ID: 1965343
1. Use a small form as a dialog with borderstyle set to 'Dialog'.Turn off the 'RecordSelectors' and 'RecordNavigation' properties because I assume there is no bound recordsource.
Use a textbox or as many as needed. Set the form's KeyPreview property to 'Yes'. That way it will receive the keystrokes before the controls. Use the form's KeyPress event to enable the OK button:
Private Sub Form1_KeyPress(KeyAscii as Integer)
     Command1.enabled = true
End sub

2. If you are looking to enable the button if there is data in the textbox, use the change events to test for "":

Private Sub Text1_Change()
    If Text1.text <> "" then 'You can use the 'and' operator to
                             'test for all necessary textboxes.
        Command1.enabled = true
    Else
       Command1.enabled = false
    End if
End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
View vs Edit mode enhancements 12 40
Direct Mail software 4 44
Match characters in text string and then parse text string in Access Query 10 23
Access 2010 Query Syntax 5 23
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…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

896 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

11 Experts available now in Live!

Get 1:1 Help Now