What's new

Need More Visual Basic Help Please! (1 Viewer)

Chuck C

Senior HTF Member
Joined
Jan 6, 2001
Messages
2,224
How do I program the OK and Cancel buttons when using the InputBox function? I keep returning an error:



right now all I have as code is

Dim strName As String

strName = InputBox("Enter StudentID", "Find StudentID")
With Adodc1.Recordset
.MoveFirst
.Find "StudentID Like '" & strName & "*'", 0, adSearchForward

my goal is to have an error message box upon clicking OK if the field is left blank and the cancel should cancel back to the form

any ideas?
thanks
 

Wayne Bundrick

Senior HTF Member
Joined
May 17, 1999
Messages
2,358
If the user clicks Cancel, a zero-length string is returned.

strName = InputBox...
if len(strName) > 0 then
... (do your stuff)
end if

There doesn't seem to be a way to distinguish between clicking Cancel and clicking OK with a blank answer.
 

Users who are viewing this thread

Sign up for our newsletter

and receive essential news, curated deals, and much more







You will only receive emails from us. We will never sell or distribute your email address to third party companies at any time.

Forum statistics

Threads
357,070
Messages
5,130,056
Members
144,283
Latest member
Nielmb
Recent bookmarks
0
Top