Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bind Datagrid to another table

Status
Not open for further replies.

Nunina

Programmer
Mar 5, 2003
128
PR
Hi!!!

I'm trying to bind a column of my datagrid to a table other than the one the grid is bound to. Any suggestions?

Thanks,

[gorgeous] Nunina
 
Nunina,

I'm not very experienced but in order to do that, I put a DataControl on my form, link the datagrid to it and set the DataControl.RecordSource property to the right SQL statement... including the different required tables. (e.g. "SELECT * FROM EMP, DEPT WHERE EMP.DEPTNO=DEPT.DEPTNO... ...")

Then I click on the "Custom" property of the datagrid, go to the 'Columns' tab, select the right column and set its Datafield property to the name of the field in the table of your choice (you can edit it without using the associated combobox).
(e.g. : DEPT_NAME)

Hope it helps...
Lemox
 
Hi, Lemox:

Thanks for answering.

I'll try it and let u know.

Thanks!

[gorgeous] Nunina
 
Hi!

Ok, here's the thing:

I have a table (table #1) that populates all my textboxes and shows other data in the grid. For example, I have an account #, which has several sub-accounts attached to it. I display the general information of the account in my textboxes (address, customer name, etc.) and the sub-account information in the grid (sub-account #, date opened, etc).

I add this information to another table (table #2). But I also include whether or not the sub-account is active, by a boolean value (Yes/No) that the user can select directly on the grid. This field is on table #2, not on table #1.

When I try to select Yes/No, I get a "column not found" error. I know this is because the grid's datasource is table #1 and not tablr #2. The grid's datasource is not the same datasource as the Yes/No column. But I need it to work!!! Why? Because I insert the information in the datagrid into table #2, including the Yes/No values. Plus my grid is multiselect, so I can insert several rows on the same click (at least that's what my user is going to see...)

So, using a query to "tie" up table #1 and table #2 is not going to work, because it is possible that there is no data on table #2, or the data is being inserted and not updated.

Suggestions????

Thanks again!!

[gorgeous] Nunina



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top