ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ad button for different rows after searcing in database (https://www.excelbanter.com/excel-programming/358590-ad-button-different-rows-after-searcing-database.html)

tsumiki

ad button for different rows after searcing in database
 

dear all,

i have a problem to add buttons with different rows after user type
keyword to search records in Access database. Button will be added an
point to the unique vid.

the searching function works but i don't know how to add row button
for user to click the differenct records. Pls help!!!

here is the code:
Private Sub CommandButton1_Click()

Dim rst As New ADODB.Recordset
rst.ActiveConnection = _
" Provider=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source=d:\db1.mdb"

keyword = Trim(TextBox1.Text)
If keyword < " " Then
strSQL = " SELECT * From summary WHERE v_id LIKE '%" & keyword
"%' " & _
"OR v_name LIKE '%" & keyword & "%' " & _
"OR t_size LIKE '%" & keyword & "%' " & _
"OR r_rate LIKE '%" & keyword & "%' Order By v_id Asc"

rst.Open strSQL
Range("A8..J100").Clear
Range("A8").Select

Do While Not rst.EOF()
For k = 0 To 4
ActiveCell.Offset(0, k).Value = rst.Fields(k)
Next
ActiveCell.Offset(1, 0).Select
rst.MoveNext
Loop
rst.Close
End If
End Sub


thanks,
tsum

--
tsumik
-----------------------------------------------------------------------
tsumiki's Profile: http://www.excelforum.com/member.php...fo&userid=3335
View this thread: http://www.excelforum.com/showthread.php?threadid=53189



All times are GMT +1. The time now is 12:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com