VBA And the Datagrid

G

Gsurfdude

Hi,

I need some help on the MS Datagrid as I need to add headers and adjust
column sizes in the grid which is read only. Can someone point me in the
direction for some code samples and or reference. It's data source is a sql
statement. I tried this

Dim dgExtract as New Datagrid

and all the objects are exposed but doesn't do what I expect. I used the OCX
control on my form and used this way and it worked:

Set Datagrid8.RecordSource = rst

and it populates. But I need to set column names and sizes etc..


Thanks.
 
A

Albert D. Kallal

While waiting perhaps for one of the very few access users that bother with
the datagrid, and take a quick view of the following screen shots:

http://www.members.shaw.ca/AlbertKallal/Articles/Grid.htm

perhaps you can dispense with that control, and use a continues form? they
are built in, and your can avoid much hassles of distribution, and also not
have to write near much the code you have to load up the display with data.
 
G

Gsurfdude

I am not aware of this. How to create this: use a continues form Next, the
main form has a tab control on it.
 
A

Albert D. Kallal

Gsurfdude said:
I am not aware of this. How to create this: use a continues form Next, the
main form has a tab control on it.

Actually the fact of the tab control does not change this issue at all. The
ability to place the data grid control, or one of several MS access controls
in that same location who will not affect your ability here.

If you take a quick read of that web link, note that you have two possible
(actually 3) possible choices to display data in a grid like control.

the first two common choices are a multi, list box, or as I mentioned you
insert a formed as a sub form, and place at sub form into what is called
continuous form mode.

Try building a few new forms with the wizard, and you'll see the choice is
there to make what is called "tabular".

Remember these continuous forms can be inserted into existing forms as a
simple control (what we call a sub form).

The advantage of using this approach is that you don't have to learn a new
type of object, but can continue to use your familiar forms object model
that you spent time learning.

I often use the form wizard as a starting point for that tabular form, and
then manually further clean it up and make it the way I wanted to look.
 
G

Gsurfdude

Ok, thanks. Looks like a continues sub form is the thing I am need to use.
Some questions for you. How did you get the column names in your continues
sub form? Next, I need to be able to select a specific item in a row in the
sub form to delete. This sub form contains 52 columns so it is big. How can I
reference an individual column??

Thanks
 
A

Albert D. Kallal

Gsurfdude said:
Ok, thanks. Looks like a continues sub form is the thing I am need to use.
Some questions for you. How did you get the column names in your continues
sub form?

When you build at continuous sub form with the wizard, it puts regular text
boxes in the forms header.

If you add a few additional columns by hand and not create a form with a
wizard, then you'll simply have to place the text boxes up top. what I
usually do is drag the field from the "view fields" list, and place the
field into the detail area of the form. At this point you'll have a text box
and a label that are connected to each other placed into the detail section.
I simply highlight the label part and edit->cut it out and paste this up
into the header area. This is a little bit more work than using a datasheet,
or list box, but I like the results, and you can make the column name
whatever you want, or even have TWO rows of text for the column. Take a look
at the 2nd screen shot here, and NOTE how there is TWO rows of text for the
header

http://www.members.shaw.ca/AlbertKallal/HideColumn/index.htm

As I said to try creating a forum using the wizard and see how it works.
Take a look at the controls in the detail section. Take a look at how the
headers appear in the heading of the form. So, do take a look at the form
and play with it and see how the form is made. I can't stress how much of a
learning experience it is to use and play with a form that been created by
the wizard.
Next, I need to be able to select a specific item in a row in the
the have that sub form to delete. This sub form contains 52 columns so it
is big. How can I
reference an individual column??

You're above question is a bit confusing. We are working with a relational
database system and a relational database engine. It actually hard to apply
the concepts of a spreadsheet to an ms-access application.

You might want rephrase the above question. Are you trying to delete a row
of data? Or, are you trying to empty a value in a particular column (field)
in this continues form? The normal way a particular field is emptied, is
that the user simply moves the cursor into that field and hits the delete
key or uses the backspace key to empty the text in that particular text box.
It's just not clear if you trying to get the user to move into a text box
and erase what's in that text box, or you looking to delete the whole row?

To delete the whole row, you simply click on the record selector and hit the
delete key, at which that point in time MS access will prompt you to confirm
the record deletion. Note that this record delete process is exactly the
same for a full normal form, and also that of a continuous form.

Keep in mind that even when you work with a continuous form, all your
controls + code and references are for the **current** active record.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top