Results 1 to 2 of 2

Thread: Input Box

  1. #1
    Join Date
    Jun 2005
    Posts
    102

    Unanswered: Input Box

    Ok, I have this procedure that runs when Switchboard is open. The problem I have is after I prompt the user for msgbox, and the user says yes to prompt, Access then prompts an inputbox which goes on a loop until the user types done and hits ENTER. During the prompt of the input box, there are two visible buttons (OK and Cancel). The OK button works only when there's data on input box, the Cancel button don't work at all. No matter how many times I hit the cancel button it just loops back to InputBox. Why is this???


    Here's the procedure.


    'InputBox properties
    Dim Message, Title2, Default, MyValue
    Message = "Enter a digit only (i.e. Type 2 for Handheld 2). Note: You must type 'Done' to cancel or exit the import process" ' Set prompt.
    Title2 = "Which Handheld?" ' Set title.
    Default = "0" ' Set default.

    'MsgBox properties
    Dim Msg, Msg2, Style, Style2, Title, Title3, Help, Ctxt, Response, MyString
    Msg = "Do you want to upload data from handheld(s)?" ' Define message.
    Msg2 = "You must type 'Done' to cancel or exit this process"
    Style = vbYesNo + vbQuestion + vbDefaultButton2 ' Define buttons.
    Style2 = vbOKOnly
    Title = "Upload Data?" ' Define title.
    Title3 = "Cancel Import"
    Help = "DEMO.HLP" ' Define Help file.
    Ctxt = 1000 ' Define topic context.

    ' Display message.
    Response = MsgBox(Msg, Style, Title, Help, Ctxt)
    If Response = vbYes Then ' User chose Yes.
    Do Until MyValue = "Done"
    MyValue = InputBox(Message, Title2, Default) ' Perform some action.
    If Response = vbNo Then
    DoCmd.OpenForm "Switchboard", acNormal, "", "", acAdd, acNormal ' Perform some action.
    End If

    Select Case MyValue
    Case 1
    SendKeys "y", False
    DoCmd.TransferText acImportDelim, "Tracer Import Specification", "tblImportTracer", "C:\Program Files\PALM\PDA1\Tracer\tracer.txt", False, ""
    Beep
    MsgBox "You have successfully imported data from handheld device 1.", vbInformation, "Import Successful"
    Case 2
    SendKeys "y", False
    DoCmd.TransferText acImportDelim, "Tracer Import Specification", "tblImportTracer", "C:\Program Files\PALM\PDA2\Tracer\tracer.txt", False, ""
    Beep
    MsgBox "You have successfully imported data from handheld device 2.", vbInformation, "Import Successful"
    Case 3
    SendKeys "y", False
    DoCmd.TransferText acImportDelim, "Tracer Import Specification", "tblImportTracer", "C:\Program Files\PALM\PDA3\Tracer\tracer.txt", False, ""
    Beep
    MsgBox "You have successfully imported data from handheld device 3.", vbInformation, "Import Successful"
    Case 4
    SendKeys "y", False
    DoCmd.TransferText acImportDelim, "Tracer Import Specification", "tblImportTracer", "C:\Program Files\PALM\PDA4\Tracer\tracer.txt", False, ""
    Beep
    MsgBox "You have successfully imported data from handheld device 4.", vbInformation, "Import Successful"
    Case 5
    SendKeys "y", False
    DoCmd.TransferText acImportDelim, "Tracer Import Specification", "tblImportTracer", "C:\Program Files\PALM\PDA5\Tracer\tracer.txt", False, ""
    Beep
    MsgBox "You have successfully imported data from handheld device 5.", vbInformation, "Import Successful"
    Case 6
    SendKeys "y", False
    DoCmd.TransferText acImportDelim, "Tracer Import Specification", "tblImportTracer", "C:\Program Files\PALM\PDA6\Tracer\tracer.txt", False, ""
    Beep
    MsgBox "You have successfully imported data from handheld device 6.", vbInformation, "Import Successful"

    End Select
    Loop
    End If

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    eh, that would be this line:

    Do Until MyValue = "Done"

    That combined with no "Case Else" makes it loop indefinately. You will need to trap the user hitting cancel or failing to provide a string at all.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

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