Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

An existing Access Database table issue

Posted on 2006-07-06
5
Medium Priority
?
190 Views
Last Modified: 2010-04-23
I have an existing Access database that has
tables (around 10). A routine that will open
any of the tables and allow the user close the
table when finished is needed.
0
Comment
Question by:farrellthrasher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 17056176
Couldn't get what you want
What do you mean Close the Table ?
What would you do after opening the tabel, would you want to insert/update some data ?
0
 

Author Comment

by:farrellthrasher
ID: 17063280
What I mean is that a routine that will allow me to access an Access database with 5 to 10 tables is needed. I would like to access any of the tables and access another table when I am finished inserting, updating or deleting data.
0
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 2000 total points
ID: 17070658
OK What I get from your query is that you want to list all the tables from your database
and then let the user select a table and work on it.
If he wants he can select another table and work on it and so on...

I am showing you the code for getting the table names from the access database showing them to user and based on the user selection showing records from the selected table to the user in a grid so that he can manipulate the data

>>>
Have a Listbox (LstTables) and a DataGridView(DGV) on your form then have this function

    Private Sub LoadTables()
        Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0......." 'Have your Connection string here
        Dim Cn As New OleDbConnection(ConStr)
        Cn.Open()
        Dim DT As DataTable = Cn.GetSchema("Tables")
        For Each dr As DataRow In DT.Rows
            If dr("TABLE_TYPE").ToString.ToUpper = "TABLE" Then LstTables.Items.Add(dr("TABLE_NAME").ToString.TrimEnd("$"))
        Next
        Cn.Close()
    End Sub

Call this function from say your Form_Load,

Also have this function to show data in Grid

    Private Sub LoadGrid(ByVal TblName As String)
        Dim Qry As String = String.Format("Select * from {0}", TblName)
        Dim DA As New OleDbDataAdapter(Qry, ConStr)
        Dim DT As New DataTable
        DA.Fill(DT)
        DGV.DataSource = DT
    End Sub

Select tables in the Listbox and you will see data populated in the Grid
This code however does not show you how to edit/update etc. the database table, you can find abundant help on the net for Updating/Inserting data into database table from a grid.

0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question