Results 1 to 4 of 4

Thread: mdb

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2002
    Posts
    586

    mdb

    Greetings,

    If I want to bring up a browse dialog box where only .mdb files are available for selection, what do I need to say. Better yet, is there any code anyone can send me so I can paste it in and try it out?

    The even to call it will be a button click called cmdAccess.

    Obviously, the idea is that when they click on the button, they can browse for a Microsoft Access Database.

    Thank you,
    Jim

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2002
    Posts
    586
    Alright, alright, just to show I'm not being a total mooch with that last question, I have this so far, below. How do I make it so that it defaults to mdb type files, or better yet, how do I make so that ONLY mdb files can be presented?
    Thank you,
    Jim

    Private Sub cmdAccess_Click()
    Dim sAnswer As String
    Dim filename As String
    Dim F As Integer
    CommonDialog1.ShowOpen
    filename = CommonDialog1.filename
    F = FreeFile
    If filename <> "" And Len(Dir(filename)) <> 0 Then
    Open filename For Input As #F
    'txtFile.Text = Input$(LOF(F), F)
    txtFile.Text = filename
    Close #F
    End If
    End Sub

  3. #3
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    VB Code:
    1. Private Sub cmdAccess_Click()
    2.     'Need this in case user clicks cancel
    3.     On Error GoTo cdlg_err
    4.    
    5.     'Setup the common dialog control and show the open file dialog
    6.     With CommonDialog1
    7.         .DialogTitle = "Microsoft Access Files"
    8.         .DefaultExt = ".mdb"
    9.         .Filter = "Microsoft Access Files|*.mdb"
    10.         .ShowOpen
    11.     End With
    12.  
    13.     Exit Sub
    14.  
    15. cdlg_err:
    16.  
    17.     'Check to see if the cancel button generated the error,
    18.     'if not, show the error message
    19.     If Err.Number <> cdlCancel Then
    20.         MsgBox "Error #" & Err.Number & vbCrLf & Err.Description
    21.     End If
    22.    
    23.     Exit Sub
    24.    
    25. End Sub

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2002
    Posts
    586
    You are THEE man!!!! (assuming you are indeed a man. Just can't picture a woman putting that for her picture.)

    Thanks again!!!
    Jim

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