Transfer 
Author Message
 Transfer

Does  any one now the code for when a datagrid loaded with data if a user
selects a line in it and then click on a command button how it will transfer
that info across to a selected text box on a form. The datagrid is connected
to access database and uses a ado connection. And the info will change for
each row the user selects.


Sun, 09 Nov 2003 16:48:12 GMT  
 Transfer
1. set a reference to the Data Binding Collection in your project
2. Try this code. The text boxes should update automatically.

Private Const strCN = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security
Info=False;Data Source=C:\Program Files\Microsoft Visual
Studio\VB98\BIBLIO.MDB"
Private cn As ADODB.Connection
Private rs As ADODB.Recordset
Dim rs1 As ADODB.Recordset
Private sSQL As String
Dim bc As BindingCollection

Private Sub Command1_Click()
    Set rs1 = New ADODB.Recordset
    'DataGrid1.Col = 0
    sSQL = "SELECT * FROM Authors WHERE AU_ID = " & DataGrid1.Text
    rs1.Open sSQL, cn, adOpenKeyset, adLockOptimistic
    Set bc = New BindingCollection
    Set bc.DataSource = rs
    bc.Add Text1, "Text", "Author", , "AU_ID"
    bc.Add Text2, "Text", "Year Born", , "AU_ID"
End Sub

Private Sub Form_Load()

    Set cn = New ADODB.Connection
    cn.Open strCN

    sSQL = "SELECT * FROM Authors"
    Set rs = New ADODB.Recordset
    With rs
        .CursorLocation = adUseClient
        .CursorType = adOpenKeyset
        .LockType = adLockOptimistic
        .Open sSQL, cn
    End With

    Set DataGrid1.DataSource = rs
End Sub


Quote:
> Does  any one now the code for when a datagrid loaded with data if a user
> selects a line in it and then click on a command button how it will
transfer
> that info across to a selected text box on a form. The datagrid is
connected
> to access database and uses a ado connection. And the info will change for
> each row the user selects.



Tue, 11 Nov 2003 02:19:53 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Monitoring Data Transfer of Internet Transfer Contol

2. Internet Transfer Control and ASCII transfer Help?

3. Internet Transfer Control and ASCII transfer Help?

4. Internet Transfer Control stalls transfer abruptly

5. Binary FTP Transfer with Inet Transfer Control

6. How to transfer a file greater than 64Kb w/ internet transfer ctrl

7. Setting transfer type in Internet Transfer Control

8. Internet Transfer Control and ASCII transfer Help?

9. ASCII vs Binary Transfer in Iternet Transfer Control

10. HOWTO: Securely transfer a file using the Internet Transfer Control

11. Winsock to transfer information...Do you know another way to transfer information??

12. Autonumber not transferring correctly anymore...

 

 
Powered by phpBB® Forum Software