Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Displaying MS Access Table in the VB Form - Help

How can I display the table created in the MS Access in the form created using VB?

Is this something to do with the data grid etc? How to set that, pls kindly give me some guidance if you know.

I am new to VB and is struggling to help someone writing a program. Settle most of the part by refering to the tutorial & sample available in the web except few items now (this table view is one of it).

BH

Comments

  • GogiGogi Member Posts: 258
    : How can I display the table created in the MS Access in the form created using VB?
    :
    : Is this something to do with the data grid etc? How to set that, pls kindly give me some guidance if you know.
    :
    : I am new to VB and is struggling to help someone writing a program. Settle most of the part by refering to the tutorial & sample available in the web except few items now (this table view is one of it).
    :
    : BH
    :

    Yes,you should use DataGrid.
    Do you use VB6 or VB.NET?
  • hooinghooing Member Posts: 4
    : : How can I display the table created in the MS Access in the form created using VB?
    : :
    : : Is this something to do with the data grid etc? How to set that, pls kindly give me some guidance if you know.
    : :
    : : I am new to VB and is struggling to help someone writing a program. Settle most of the part by refering to the tutorial & sample available in the web except few items now (this table view is one of it).
    : :
    : : BH
    : :
    :
    : Yes,you should use DataGrid.
    : Do you use VB6 or VB.NET?
    :

    I use VB6, can that be done with VB6?
    I saw some tutorial on VB.NET for this datagrid but couldn't find it for VB6.
  • GogiGogi Member Posts: 258
    : : : How can I display the table created in the MS Access in the form created using VB?
    : : :
    : : : Is this something to do with the data grid etc? How to set that, pls kindly give me some guidance if you know.
    : : :
    : : : I am new to VB and is struggling to help someone writing a program. Settle most of the part by refering to the tutorial & sample available in the web except few items now (this table view is one of it).
    : : :
    : : : BH
    : : :
    : :
    : : Yes,you should use DataGrid.
    : : Do you use VB6 or VB.NET?
    : :
    :
    : I use VB6, can that be done with VB6?
    : I saw some tutorial on VB.NET for this datagrid but couldn't find it for VB6.
    :

    OK,here's a way how to do this,step by stem (I had no time until now,sorry):
    1.)Create Access DB
    2.)Create VB form
    3.)Put a DataGrid control on it.
    4.)Put an Adodc control on the form
    5.)Select Adodc control
    6.)Select ConnectionString property. Click "..." button.
    7.)Check option "Use connection string" and click "Build..." button near it.
    8.)From the list of providers,double click "Microsoft Jet 4.0 OLE DB Provider".
    9.)Now hit "..." button near select database name textbox,and find your database file.
    10.)Click OK two times to close both opened windows.
    11.)Enter this in RecordSource property of your Adodc control:
    Select * FROM your_table_name
    11.)Use this code in Form_Load event:
    [code]
    Private Sub Form_Load()
    Adodc1.Refresh
    Set DataGrid1.DataSource = Adodc1
    End Sub
    [/code]


    Now run your program,and you should have the Access table content shown on your form!

    I hope this helps!

    Gogi
  • hooinghooing Member Posts: 4
    : : : : How can I display the table created in the MS Access in the form created using VB?
    : : : :
    : : : : Is this something to do with the data grid etc? How to set that, pls kindly give me some guidance if you know.
    : : : :
    : : : : I am new to VB and is struggling to help someone writing a program. Settle most of the part by refering to the tutorial & sample available in the web except few items now (this table view is one of it).
    : : : :
    : : : : BH
    : : : :
    : : :
    : : : Yes,you should use DataGrid.
    : : : Do you use VB6 or VB.NET?
    : : :
    : :
    : : I use VB6, can that be done with VB6?
    : : I saw some tutorial on VB.NET for this datagrid but couldn't find it for VB6.
    : :
    :
    : OK,here's a way how to do this,step by stem (I had no time until now,sorry):
    : 1.)Create Access DB
    : 2.)Create VB form
    : 3.)Put a DataGrid control on it.
    : 4.)Put an Adodc control on the form
    : 5.)Select Adodc control
    : 6.)Select ConnectionString property. Click "..." button.
    : 7.)Check option "Use connection string" and click "Build..." button near it.
    : 8.)From the list of providers,double click "Microsoft Jet 4.0 OLE DB Provider".
    : 9.)Now hit "..." button near select database name textbox,and find your database file.
    : 10.)Click OK two times to close both opened windows.
    : 11.)Enter this in RecordSource property of your Adodc control:
    : Select * FROM your_table_name
    : 11.)Use this code in Form_Load event:
    : [code]
    : Private Sub Form_Load()
    : Adodc1.Refresh
    : Set DataGrid1.DataSource = Adodc1
    : End Sub
    : [/code]
    :
    :
    : Now run your program,and you should have the Access table content shown on your form!
    :
    : I hope this helps!
    :
    : Gogi
    :

    Really appreciate your help and the details step by step.
    I manage to find the way to show the "data grid" control from the component and link the access to VB.
    The program is temporary up & running even there is still some bugs that need to be solved.

    Thanks again & it definitely help.

    BH
  • sray_and_a_mansray_and_a_man Member Posts: 3
    hello,
    i tried to connect access 2000 with vb as per the method stated. but i connected the fields with text boxes. it got connected, but before displaying data an error "unrecognised data format" comes. how to rectify the problem.
  • tyrone8888tyrone8888 Member Posts: 1
    Hello

    i'm new to this site and dont know just yet how to create a new thread.
    I'm quite new to visual basic 6 and would like some help designing a program.

    -Using visual basic 6 to connect to a Microsoft Access 2000 database
    - using a Microsoft ActiveX Data Objects Library

    I want to connect a combo box to a databae, for example if the user clicks on the combo box the names of the tables should appear. When the user clicks on the table name its attributes should be displayed in a list box below the combo box.

    Can anyone help write the code to accomplish this

    Thank you

    Here's my attempt to to display the table names in the combo box, this works perfectly fine apart from that it display unnecessary information in the combo such as MSys
    Access Objects, MSysACEs,MSysObjects. All i want is thecombo box to display these three tables which are Attainment,Student Module. plus i want the user to select the table name and its attributes are displayed in a list box

    [vbcode]Option Explicit

    Private Cn As ADODB.Connection ' This is the connection
    Private rstSchema As ADODB.Recordset ' This is the recordset
    Private strCn As String ' string to be used in the code
    Public strSelectedItem As String
    Private Sub OpenDB()
    Set Cn = New ADODB.Connection 'Declared it as a ADODB connection
    strCn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=c:Documents and Settings
    ewResults.mdb" 'A connection string that is connected to the database
    Cn.Open strCn
    End Sub
    Private Sub Form_Load()
    ' retrieve all the information from the database and places it in the combobox
    OpenDB
    Set rstSchema = Cn.OpenSchema(adSchemaTables)

    Do Until rstSchema.EOF
    cboTables.AddItem " " & rstSchema!TABLE_NAME
    rstSchema.MoveNext
    Loop

    End Sub[/vbcode]
Sign In or Register to comment.