Solved

vbOK

Posted on 1998-10-14
6
394 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

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…
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…
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…
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…

810 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