Microsoft DataGrid Control - interactive grid on a form

Huw Davies

New Member
Joined
Aug 26, 2005
Messages
20
Can anyone give me simple instructions on how to put a grid control on an Access form and link it interactively with a query in the database. A small working example would be wonderful.
 

Some videos you may like

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

mdmilner

Well-known Member
Joined
Apr 30, 2003
Messages
1,352
Disclaimer: I may not have an opportunity to comment again for a couple days.

Question - What version of Access & VB are you using? If I'm not mistaken, Datagrids are a .Net control. Are you linking to an external non-access database?

Now, if you're talking about a Dataview - just a display view for a query, try opening up a new form and selecting a table or query to bind to it and then select dataview as the default way it displays the results inside the form.

If you start peeking around at the form properties in design mode, you'll find some entries in the Recordsource or Rowsource properties that relate to the choices you made using the wizard interface.

Mike
 

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
Within design view of a form, you have the choice of Single Record, Multiple Records, or DataSheet view. The DataSheet sounds like what you are asking for.

Create a form with the fields you want on it, set the Default View (Format tab, properties dialog) to Datasheet, then when you open the form, you will see the "grid" I think you are looking for.
HTH,
 

Huw Davies

New Member
Joined
Aug 26, 2005
Messages
20
I'm using Access 2003 under XP prof. The control that I'm looking at is an ocx control called "VideoSoft FlexArray Control" that came with Access. It paints a very nice configurable grid control on a form but I can't find any way to link it to data. Alternatively I found an Excel type grid called Microsoft Office Spreadsheet 11.0 and I can't find any way to link that to data either. I don't really want to simulate a grid using a data sheet. I'm actually trying to work towards an interactive Sasco type chart.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,539
Office Version
365
Platform
Windows
Huw

A Sasco type chart?:eek:

Sorry, I don't actually know what that is.:)

I'll perhaps have a wee look on the web to find out what that is.

In the meantime I would recommend that you have a rethink about using non-standard controls.

If you are developing this across multiple users/platforms/versions then you might find yourself running in to problems.
 

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
As Vic mentioned, use a subform and display it in Datasheet mode -- that is the simplest way to show one-to-many datasets in Access.

If you really need a flexgrid, here is a link that may help. To be honest, there's not a lot of useful info out there for Access and Flexgrids -- they are really intended more for VB and VB.Net projects.

Hope this helps

Denis
 

mdmilner

Well-known Member
Joined
Apr 30, 2003
Messages
1,352
I have no idea if this will help you. I've never used that particular object within Access, however, I have done a limited amount of work with datagrids in .Net.

Datagrids in .Net work in a fashion that really is completely different from recordsets and ADODB type connections. This is a snippet from some code I wrote, however, it's pretty generic so I included it here. Again, to emphasize, this is not VB6.0.



Code:
            adapter = New OleDb.OleDbDataAdapter(sqlStatement, connection)
            accessData = New DataTable("theData")

            Dim ds As DataSet
            ds = New DataSet("theData")
            ds.Tables.Add(accessData)
            dgResults.DataSource = ds
            adapter.Fill(accessData)

            'Clear any bindings from the DataGrid and set the DataSource of the DataGrid 
            'to the new excelData DataTable 
            dgResults.DataBindings.Clear()
            dgResults.DataSource = accessData
Working with individual records and/or fields requires you to work wish DataColumn & DataRow objects.

I'm thinking you'll do better to work with something else, however.

Mike
 

Watch MrExcel Video

Forum statistics

Threads
1,095,544
Messages
5,445,099
Members
405,316
Latest member
joaoamaro

This Week's Hot Topics

Top