Solved

vbOK

Posted on 1998-10-14
6
403 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

831 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