DATAGRID CONTROL

  • Thread starter Thread starter Paul Martin
  • Start date Start date
P

Paul Martin

Hi All,

I want to use a datagrid control on one of my forms to display a recordset.
Unfortunately, I just can't seem to work out how I actually tell it what
recordset to use. Could anyone please point me in the right direction?

Thanks

Paul
 
You also don't mention what datagrid control you are using. There is a LOT
data controls that you can purchase.

Also, I often use continues forms in ms-cess. If you look at the following
screen shots, I used continues forms, and they function as rather nice
grids.

http://www.attcanada.net/~kallal.msn/Search/index.html

You can also often used a listbox as a grid also. If you look at the
following screen shot, on the left side is a listbox, and on the right side
I used a sub form. I used a sub-form on the right side, since I wanted to
show check box...and you can't do that with a listbox, but you sure can
with a sub-form in continues mode.

Here is that screen
http://www.attcanada.net/~kallal.msn/test/gs1.gif
 
Hi Dan,
The reason for not using a subform (set to datagrid) is that in fact I am
trying to resolve a problem for which I failed to get a subform to work. I
am actually building a system for creating some pretty complex price lists
where the user detrmines how many price columns he / she wants for each
given range of products, and sets the name for the column. Each column has a
GPM set, and so it effectively becomes a straight calculation from the
purchase price. Each column is given a priority (supposed to be used for
displaying the columns in the correct order). In order to actually do the
calculations and display as price columns I use a cross-tab query (which I
dump into a temp table so the user can actually make changes, and the
changes are only updated to the database when the save button is pushed).
Unfortunately, the only way I could find of displaying the columns in the
correct order was to concatenate the priority field with the users name for
the column. Add to this the problem of not knowing in advance how many
columns each product range will have applied to it, the only way I could see
of using the standard datagrid control would be to over-estimate how many
price columns are likely to be used, and then somehow to hide columns that
are empty (which I may well have to resort to, but goes against the design
concept of offering the greatest flexibility).
I really don't know if the datagrid control will actually help resolve the
problems here, I just wanted to explore the possibilities (and I figured the
user would at least be able to manually change the order of the columns so
that I could take out the priority field concatenated with the column name).
Sorry for the wordy reply, but I do hope this helps you to understand my
motives for looking at an alternative to simply building a standard subform.
Thanks & Regards,
Paul
 
Hi Albert,
Thanks for your suggestions. In answer to your first question, the
particular control I picked our was the Microsoft DataGrid Control 6.0
(SP5). I think this was one of the tools that came with the Office 2000
Development Tools, but I guess it could just as easily have come with VB6.
I've outlined the specific problems I'm working in with my reply to Dan, so
I won't repeat it all here - only to say I don't know in advance how many
columns I will require - or even what the column names would be. I myself
use continuous forms frequently, but in this particular case I can't find a
way of achieving what I want. The alternative of using a listbox has the
same problem. I can create a listbox from a recordset, but I have no idea
how the user could then alter the widths of the columns so that they can
read all of the data clearly (product names can be quite long, and the
prices are displayed to 4 decimal places, but some products may be several
thousand pounds, some are fractions of a penny).
Hope this better explains my motives.
Thanks again.
Paul
 
Hi,
I always use datagrids. I set the source in the VB code of the form
datagrid.recordsource = rs
From code you can format the grid eg

Dim col1 As Column

Set col1 = rs.Columns(0)
col1.Caption = "Part No"
col1.Width = 2000

If anyone else has any input on better ways of doing this I would be
grateful - I struggled to find any info regarding the datagrid control

HTH

Al
 
You need to use an ADO recordset and set IRowsetIdentity = true

rstADO.Properties("IRowsetIdentity") = True

Open the recordset then

Set Me.DataGridControl.DataSource = rstADO

Jose
 
If the provider is Mcrosoft.Jet.OLEDB.4.0 and the CursorLocation is
adUseServer (default) then you need to
set rstADO.Properties("IRowsetIdentity") = True otherwise the datagrid will
not be populated.

For more info see Microsoft Knowledge Base Article Q224192
DataGrid Is Not Populated Using Jet.OLEDB.4.0 Provider and ADO Server Side
Cursor
http://support.microsoft.com/support/kb/articles/q224/1/92.asp


Jose
 
Back
Top