Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004

    Unanswered: newbie to vb and access

    basically im trying to do a school project and i want to display a MS access database within a form so it looks smart. i can do all the maniuplation of the database through ms access. any help woould be very much appreciated!

  2. #2
    Join Date
    Sep 2004
    Hello Peter,

    The easiest way to view an MS Access database within a VB form is to use a Datagrid attached to an ADO Data Control.

    1) Create a new project and a new form

    2) In VB 6 open Project->Components and click the boxes for "Microsoft ADO Data Control 6.0" and also "Microsoft DataGrid Control 6.0". In the VB Toolbox at left you will see two new icons appearing. If not, open the VB Toolbox by clicking View->Toolbox

    3) Now drag both new icons onto your new form

    4) Right click the ADO Data control and select ADODC Properties->Build Connection String.

    5) Choose your desired data connection to the Access table (I suggest Microsoft Jet 4.0 OLE DB Provider). Click "Next" to find your Access database click "Test Connection". If all is OK, click "OK" to proceed!

    6) Click the RecordSource tab, drop down the Commad Type list box and choose "2 - adCmdTable", drop down the Table List box and find your table. Click on to proceed. Click OK. You now have an active connection to the database using ADO.

    7) Now click on the Datagrid and in the right hand "Properties" window, look for Data->Datasource. Drop down the list and click on the "Adodc1" data control entry (or whatever you named the data control).

    8) Right click on the Datagrid in the newly created form and choose "Retrieve Fields". Click "Yes" when asked if you want to replace existing grid layout. Expand the form and drag the datagrid to the desired size and position on your form.

    9) Add a command button to the form, enter the Caption "Exit" in the Properties windows at left, double-click it and enter the following code in the Code window :

    Private Sub Command1_Click()
    unload me
    End Sub

    (The first and last lines are already written for you).

    Now run your form to see the results.

    If you want to further tweak the layout and the column order/contents, look up Help in VB on how to do this.

    Hope this helps!

    Peter Tyler

  3. #3
    Join Date
    Oct 2004
    thx dude u are a lifesaver!

Posting Permissions

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