vba - How to populate listbox of MS access on Button Click Event -
i have sub in vba fetching data database on button click event below
public sub getnearestpfk(runnr integer) dim db dao.database dim rs dao.recordset dim sqlstring string dim record object dim objpfk pfk dim integer = 0 set db = currentdb sqlstring = " select top 5 t_temp_destance_cal.* t_temp_destance_cal runid = " & runnr & " order distance " msgbox (sqlstringgetnearestpfk) set rs = db.openrecordset(sqlstring) until rs.eof objpfk.id = rs!id objpfk.fistname = rs!firstname objpfk.lastname = rs!lastname objpfk.distance = rs!distance objpfk.duration = rs!duration objpfk.address = rs!address arrayobjpfk(i) = objpfk rs.movenext = + 1 loop rs.close set rs = nothing set db = nothing end sub
now have data want display
how should display data in listbox on button click listbox populate
you can set list box property called row source type table/query
, row source property sql statement.
if want update list box, update row source.
Comments
Post a Comment