Solved

vbOK

Posted on 1998-10-14
6
373 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

746 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

17 Experts available now in Live!

Get 1:1 Help Now