DataGrid Control

D

Dib

Hi,
Does anyone have a sample code on how to connect a table or Query to a
DataGrid Control (ActiveX).

I could not figure it out using Access 2000. Iwas able to get it to work in
VB 6.

Thanks
Dib
 
A

Albert D. Kallal

The same code you use in VB generally will work with ms-access.

Of course, how you connect to the data source generally is a bit different,
but the code generally is the same to "fill" the grid. Further, most of the
VB data aware controls need to use a recordset/connection object that is
placed on the form/screen. (this is because the forms in VB are not data
bound). You the bind your datagrid to that control for the data source. And,
often, you just have to write code to fill the grid row by row if the
control cannot be data bound direct (the tree view is a good example here).

So, the LARGE number of examples on the web concerning VB and the DataGrid
should work for you (you make no mention of what part did not work?).

However, before you do jump in and use a grid, any reason why you don't use
a continues form, or a multi-column listbox in access? Either a continues
form, or a listbox makes a VERY NICE grid display in ms-access.

Take a look at the following ms-access screens shots, and note how WELL
ms-access can simulate grid controls. Not only does ms-access do a great
job, but it is FAR LESS work then using a grid control, and the results are
FAR BETTER and FAR MORE flexible and MORE powerful. So, we have better,
faster, easier, more flexible, less code etc.

Check out the following screen shots:

http://www.attcanada.net/~kallal.msn/Articles/Grid.htm
 
D

Dib

Thank you for taking the time to reply back.
I am trying to be able create something like a continues form, but I need to
be able to add a new field across when ever the user enters data in the
first one, I could not figure it out using continues form or list box. I
used the MSFlex Grid but I could not figure out how to enter data into the
Flexgrid, the Data Grid control to me was the best soulation.

The problem I got using the Data Grid in Access is that it need to have an
ADO connection.
is there a way I can download a sample of the program from which the Screen
shot came from.

Thanks
Dib
 
A

Albert D. Kallal

is there a way I can download a sample of the program from which the
Screen
shot came from.

I don't have a sample download of those exact screen shots, but they are
dead simple to make. I will try in the future to put up a few examples.

If you are able to be playing around with the ms-flex grid control, then one
MOST CERTAINLY must be able to place a few text boxes on a screen, and use
continues mode!

Of course, in addition to simple text boxes on that you place on the access
form, you can most certainly place a button on the form also (my example
screen shots did this, and you can see how the button repeats). So, if you
can use a mouse and can put few text boxes on a ms-access form, then you
have all the skills you need to create continues forms like those screen
shots.

While the above type forms are easy to make, and usually requite very little
code, those screen shots do in fact use some code for the buttons. The
button code in those example forms is usually as follows:

docmd.OpenForm "FormName",,,"id = " & me.id

Thus, the above button code in those screen shots generally opens a another
regular normal form that opens to the ONE record that the user had selected.
So, the code that opens a form for more details is really only one line of
code in ms-access! Is not ms-access incredible in how little code it takes
to do such a cool task? (so, the above code opens a new form to the one
record for editing!).

So, simply dragging a few text boxes onto a form and a tiny amount of code
is all that you need to create a continues form that is similar to those
screen shots. I also of course added a few text boxes at the top of those
screens for searching, but again, the code is some simple sql.

There is no special magic I used, and if you can't simply place a few text
boxes on a form and change the form into continuous mode, then you need to
get a few books on using ms-access. Placing text boxes on a form is not very
hard. Perhaps you still using the wizards to make your forms in ms-access?

It is possible I am not understanding what you are tying to accomplish?

I can't quite figure out what you mean by:
need to
be able to add a new field across when ever the user enters data in the
first one, I could not figure it out using continues form or list box

Hum, I don't understand what you mean by "new field across"? Do you know
what this field is going to be, or in fact is adding a "new" field the
problem here? We don't generally add new fields to a table at runtime in
access.

Also:
"the user enters data in the first one"

Do you mean another form, or simply the "first one" "grid" here on the
current form?

Perhaps you might explain what you are tying to do. It is very possible that
continues forms MAY NOT be what you need here! This would mean that I am
sending you on a wild goose chase, and not helping you at all!
 
D

Dib

Thanks for the information.

I am trying to create a doctors visit program. this one Form needs to be
able to add Blood work result, some Patients do this every 3 month so I need
the user to be able to enter this information in a straight line for 15
different types of testing. this include Date of test done and result value.

Thank you I will try and work with the information you sent me.

Dib
 
A

Albert D. Kallal

Ah, ok, this sounds like the classic one to many type relation.

So, you have a table called tblVists.

tblVisits:
[id]
[patient_id]
[VistDate]

I sure you have all kinds of additional fields and info for this "visit"
table.

Of coupe, since you might have 2 tests, or 20 tests, then we need a relation
here (each visit might have "one" or "many" tests Hence, a one to "many"
relation is needed here).
Thus we simply make a another table called tblTests. We will then relate the
test table to the visits table for each visit.

Thus, the entry of test data can be on a visits form, and the tests stuff
will be a sub-form. Sub-forms are the classic way we handle the "many" side.
So, just like a invoice that has "many" lines of detail that you enter, the
exact same concept would apply to your visits form. So, your continues form
for entering the "many" tests will of course be a sub-form, and it will also
be a continues form!
 

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

Similar Threads


Top