Need More Visual Basic Help Please!

Discussion in 'Archived Threads 2001-2004' started by Chuck C, Dec 2, 2002.

  1. Chuck C

    Chuck C Cinematographer

    Joined:
    Jan 6, 2001
    Messages:
    2,224
    Likes Received:
    1
    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
     
  2. Wayne Bundrick

    Wayne Bundrick Cinematographer

    Joined:
    May 17, 1999
    Messages:
    2,358
    Likes Received:
    0
    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.
     
  3. Chuck C

    Chuck C Cinematographer

    Joined:
    Jan 6, 2001
    Messages:
    2,224
    Likes Received:
    1
    thanks for the reply wayne...

    edited out...
     
  4. Chuck C

    Chuck C Cinematographer

    Joined:
    Jan 6, 2001
    Messages:
    2,224
    Likes Received:
    1
    edit:nevermind
     

Share This Page