# Connect to MS Access using Tkinter

**URL:** <https://discuss.python.org/t/connect-to-ms-access-using-tkinter/15712>\
**Category:** Python Help\
**Created:** [May 12, 2022, 10:38pm UTC](https://discuss.python.org/t/connect-to-ms-access-using-tkinter/15712 "2022-05-12T22:38:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![giszzmo](https://avatars.discourse-cdn.com/v4/letter/g/e36b37/32.png) [@giszzmo](https://discuss.python.org/u/giszzmo)\
**Post date:** [May 12, 2022, 10:38pm UTC](https://discuss.python.org/t/connect-to-ms-access-using-tkinter/15712/1 "2022-05-12T22:38:44Z")

</div>

I am trying to create a GUI using tkinter and I know how to connect to MS access but how do I connect to it using tkinter with a file open button. If anyone could point me in the right direction.

---

<div class="post-metadata">

**Author:** ![rob42](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rob42/32/8218_2.png) [@rob42](https://discuss.python.org/u/rob42)\
**Post date:** [May 12, 2022, 11:05pm UTC](https://discuss.python.org/t/connect-to-ms-access-using-tkinter/15712/2 "2022-05-12T23:05:38Z")

</div>

I’m new to tkinter myself, so I’ve yet to create a working app that uses file access, but I’ve started to gather some info and put this together as tester; I hope you find it of use.

```python
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog as fd
from tkinter.messagebox import showinfo

root = tk.Tk()
root.title('Tkinter Open File Dialog')
root.resizable(False, False)
root.geometry('300x150')

def select_file():
    filetypes = (
        ('Text files','*.txt'),
        ('All files', '*.*')
    )

    filename = fd.askopenfilename(
        title='Open a file',
        initialdir='/home/',
        filetypes=filetypes)

    showinfo(
        title='Selected File',
        message=filename
    )

# open button
open_button = ttk.Button(
    root,
    text='Open a File',
    command=select_file
)

open_button.pack(expand=True)

# run the application
root.mainloop()

```
