Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    InputBox (Access2000)

    I want to use the following code. The user inputs the data and hits enter 2 x's. This then runs another code ...blah blah blah...

    I created a very small form for the InputBox to work in and DON'T want to have a "close" button on the form, but need to provide an "OUT" for the user should they get to this form via the switchboard in error.

    The following code (is in the OnOpen Event of the form) doesn't want to cooperate with me....OR perhaps...I'm the dummy...I believe it's the latter....LOL

    On Error GoTo Form_Open_Err

    Dim strInput As String, strMsg As String, strHW As String

    strMsg = "Enter Export Date Like: 020203"

    If strInput = InputBox(strMsg) = vbOK Then
    strHW = strInput
    Me.txtExportDate = "DME" & strHW

    Else
    DoCmd.Close acForm, "frmCleanUp"

    End If

    Form_Open_Exit:
    Exit Sub

    Form_Open_Err:
    MsgBox Error$
    Resume Form_Open_Exit

    Can someone offer a suggestion to me as to WHY? The form closes no matter whether I select "OK" or "Cancel"

    Thanks in advance.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  2. #2
    Lounger
    Join Date
    Mar 2003
    Location
    Gainesville, Florida, USA
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: InputBox (Access2000)

    Hi, I'm not sure if this answers your question but your current code returns a blank string everytime therefore it closes the form.

    You may want to try the following:

    On Error GoTo Form_Open_Err

    Dim strInput As String, strMsg As String, strHW As String

    strMsg = "Enter Export Date Like: 020203"

    strHW = InputBox(strMsg)
    '****** if you enter something in the input box AND hit enter or OK then
    '****** then you will get a string result.
    '****** Otherwise leaving it blank or hitting cancel will return a "".
    If strHW <> "" Then

    Me.txtExportDate = "DME" & strHW

    Else
    DoCmd.Close acForm, "frmCleanUp"

    End If

    Form_Open_Exit:
    Exit Sub

    Form_Open_Err:
    MsgBox Error$
    Resume Form_Open_Exit

  3. #3
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: InputBox (Access2000)

    Michael,

    Thanks....works perfectly!!!!
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •