Results 1 to 5 of 5

Thread: Commondialog question

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    MO
    Posts
    24
    I am using the CommonDialog and it selects my file fine but if you go to another text box on the form and type some information and happen to hit enter it pulls up the Showopen again? How do I get it to stop doing this?
    Intensejp

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    you must have Focus set to your command button
    Posting your code would help one to see what is happening.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    MO
    Posts
    24
    Code:
    Private Sub Command1_Click()
      If Check2 = 0 Then
        
        
        ' Set CancelError is True
        CommonDialog1.CancelError = True
        On Error GoTo ErrHandler
        ' Set flags
        CommonDialog1.Flags = cdlOFNExplorer Or cdlOFNHideReadOnly
        ' Set filters
        CommonDialog1.Filter = "All Files (*.*)|*.*|Text Files" & _
        "(*.txt)|*.txt|Batch Files (*.bat)|*.bat"
        ' Specify default filter
        CommonDialog1.FilterIndex = 1
        ' Display the Open dialog box
        CommonDialog1.ShowOpen
        ' Display name of selected file
        UploadFile = CommonDialog1.FileName
        Exit Sub
      Else
      Dim strResFolder As String
       strResFolder = BrowseForFolder(hWnd, "Please select a folder.")
        If strResFolder = "" Then
           Call MsgBox("The Cancel button was pressed.", vbExclamation)
        Else
        UploadFile = strResFolder
        End If
        CommonDialog1.
        
    ErrHandler:
        'User pressed the Cancel button
        Exit Sub
     End If
    End Sub
    Are you saying that I can just set the Command1 button to lostfocus?
    Intensejp

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Perhaps your default focus is the commandbutton
    Ie...if Command1.Default = True then whenever you hit enter you will activate the code in the button.

    Put this in your form load event and try it.
    Command1.Default = False
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    MO
    Posts
    24
    Thank you the Command1 button was set to the Default--you guys are good.
    Intensejp

Posting Permissions

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



Click Here to Expand Forum to Full Width