I use the recordset method so you can put something like this in your Click event....
Dim cxn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String
Set cxn = New ADODB.Connection
Set rst = New ADODB.Recordset
'I use an Access DB if you use something else - like SQL -
'your connection will be a bit different
With cxn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
"add the absolute path to your data here"
.Open
End With
strSQL = _
"SELECT MyTable.strAuthorName" & _
"FROM MyTable " & _
"WHERE MyTable.intAuthorID= " & MyForm.TextBoxi & ";"
rst.Open strSQL, cxn, adOpenStatic, adLockReadOnly, adCmdText
txtResult.Text = rst!strAuthorName
rst.Close
Set rst = Nothing
cxn.Close
Set cxn = Nothing
Hope this helps you out.....
Kenny Alligood
|