Link to home
Start Free TrialLog in
Avatar of s_ling
s_ling

asked on

DBGrid

Hi,

I would like to know how can I display, add, delete, edit  the records  in unbound DBGrid.

The fields for the DBGrid are Tree No, Species Code, Type, Diameter(cm), Height(m) and Volume(m3).

---------
tree no, species code, diameter, height and volume are in table called ASM while type is in table called SPECY in access.
--------

after the users get to this form, the system needs to display the records in DBGrid before allow the users to add, edit, delete.
to display the records, the system needs to find in ASM table for "PECREFNO", "BLOCK NO", "BLOCK AREA", "STRIP NO", "STRIP AREA".  

If under the  "PECREFNO", "BLOCK NO", "BLOCK AREA", "STRIP NO", "STRIP AREA", got records for Tree No, Species Code, Type, Diameter(cm), Height(m) and Volum(m3). Then, display it and allow the users to edit or delete.  if not, allow the users to add.

besides, is that possible for me to do renumbering (for tree no) and set the function like combo box (for species code) in DBGrid.  
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of s_ling
s_ling

ASKER

Hi TimCottee,

There is a compile error "Invalid Outside Procedure" in line "Set rst = New ADODB.Recordset". What's wrong with that?

Besides, if I want to join a field from another table in the column(2) of the datagrid1, how can I write? is that possible for the column to show the records automatically after the users selected the "SPECIES CODE" from the column that has combo box function? for example, "MRPX" is one of the species code. After the users selected "MRPX", the next column will show the "TYPE" for "MRPX" automatically. For example, "01".  
Avatar of s_ling

ASKER

Hi TimCottee,

There is a compile error "Invalid Outside Procedure" in line "Set rst = New ADODB.Recordset". What's wrong with that?

Besides, if I want to join a field from another table in the column(2) of the datagrid1, how can I write? is that possible for the column to show the records automatically after the users selected the "SPECIES CODE" from the column that has combo box function? for example, "MRPX" is one of the species code. After the users selected "MRPX", the next column will show the "TYPE" for "MRPX" automatically. For example, "01".  

Avatar of s_ling

ASKER

Hi TimCottee,

There is a compile error "Invalid Outside Procedure" in line "Set rst = New ADODB.Recordset". What's wrong with that?

Besides, if I want to join a field from another table in the column(2) of the datagrid1, how can I write? is that possible for the column to show the records automatically after the users selected the "SPECIES CODE" from the column that has combo box function? for example, "MRPX" is one of the species code. After the users selected "MRPX", the next column will show the "TYPE" for "MRPX" automatically. For example, "01".  

s_ling, apologies, I don't seem to have been getting any notifications on this one.

The section you have a problem with is not intended to be pasted directly into the code window. You need to include this probably in the Form_Load event code. Except for the Dim statement which should be in the declarations section of the form.

As for joining another table, I thought that initially your requirement was for the grid not to be bound to a database. If you want to have a join in the grid then you must create the select statement to join two tables and then display them. However perhaps that is not what you are really asking for. By all means you can use the Click event of the combo box to retrieve the matching detail from a database table when selected and populate a specific column in the grid. This though is not really a joining of tables, more of a lookup.
Avatar of s_ling

ASKER

TimCottee,

I didn't bound the data grid to a database.
Actually is that possible for me to display the records and at the same time allow add, save, modify and delete in data grid?
Avatar of DanRollins
Hi s_ling,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept TimCottee's comment(s) as an answer.

s_ling, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Per recommendation, force-accepted.

Netminder
CS Moderator