hi :) can anyone tell me how to pass data from datagrid to several textboxes. I have a textbox where the user can search a data. The data searched would display in the datagrid, so when I clicked on a data from the datagrid, it will be distributed to their respective places. I've done searching for it but I can't seem to find the right way to do it.
I'm using MS Access 2003 and Visual Basic 6.0.

Hope you can help me. :)

Recommended Answers

All 6 Replies

Hi Problematic. It seems that I have missed your post being new year and all.:)

You can try the following -

Text1.Text = Datagrid1.TextMatrix(Datagrid1.Row, 1) 'The 1 at the end refers to the coloumn value in the grid, in this case coloumn 1...

Have you tried binding the text box to a column in the datasource that supplies the datagrid.

@Chris, I think if you bind the textbox to the recordsource, it will only load the data from the last row. Once the data has been loaded to the grid there i no more interaction with the datasource.

The code that I have supplied above will load the text box with a value every time a row is selected in the datagrid.

That is not my understanding. A bound textbox displays the data at the cursor, ie the current row in the datagrid.

further to earlier comment see attached screen capture for example

commented: Nice! +6

I do apologize, I did not know that you were making use of a data control. That way the bound text boxes will show the values. This will however not work in making use of ADO etc.

Some kudos for overseeing the obvious.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.