CaptainGiblets
asked on
Sql select results to text boxes access 2010
i want to run a select query which will return 5 columns and 20 rows.
I have a form that has a 5x20 grid of text boxes, and i want to paste the results from the select query into these text boxes.
How can i do this?
I have a form that has a 5x20 grid of text boxes, and i want to paste the results from the select query into these text boxes.
How can i do this?
ASKER
I have another 2 sets of 20 boxes that will be filled out, and then a submit button to be pressed to enter that data into the form. However they cant be linked controls as many checks need to be performed on the entered data before they are ammended to the the database.
* Not really sure why you want to do this, you can use a bound form and life will be easy.
anyway, if you want to use an unbound form
(btw, you can not copy the result of the query and paste it to an open unbound form)
open select query as recordset
set rs=currentdb.openrecordset ("yoursele ctquerynam e")
me.text1=rs.Fields(0) ' or me.text1=rs!NameOfField1
me.text2=rs.Fields(1) ' or me.text1=rs!NameOfField2
etc...
anyway, if you want to use an unbound form
(btw, you can not copy the result of the query and paste it to an open unbound form)
open select query as recordset
set rs=currentdb.openrecordset
me.text1=rs.Fields(0) ' or me.text1=rs!NameOfField1
me.text2=rs.Fields(1) ' or me.text1=rs!NameOfField2
etc...
ASKER
its not a view from sql the actual query i run is
"select Auto, [Date Recorded], Name, [Trading As Name], [Date Sent], Terms, MD, [MD2], [Administrator ] from V_Sentto where v_sentto.[Administratrator ] = '" & Me.cboadmin & "'"
"select Auto, [Date Recorded], Name, [Trading As Name], [Date Sent], Terms, MD, [MD2], [Administrator ] from V_Sentto where v_sentto.[Administratrator
you can do this, then
dim ssql as string, rs as dao.recordset
ssql="select Auto, [Date Recorded], Name, [Trading As Name], [Date Sent], Terms, MD, [MD2], [Administrator ] from V_Sentto where v_sentto.[Administratrator ] = '" & Me.cboadmin & "'"
set rs=currentdb.openrecordset (ssql)
if rs.eof then exit sub
me.text1=rs.Fields(0) ' or me.text1=rs!NameOfField1
me.text2=rs.Fields(1) ' or me.text1=rs!NameOfField2
dim ssql as string, rs as dao.recordset
ssql="select Auto, [Date Recorded], Name, [Trading As Name], [Date Sent], Terms, MD, [MD2], [Administrator ] from V_Sentto where v_sentto.[Administratrator
set rs=currentdb.openrecordset
if rs.eof then exit sub
me.text1=rs.Fields(0) ' or me.text1=rs!NameOfField1
me.text2=rs.Fields(1) ' or me.text1=rs!NameOfField2
ASKER
Set rs = CurrentDb.OpenRecordset(ss ql)
returns error object variable or With block variable not set... Is this because it is an ADP database?
returns error object variable or With block variable not set... Is this because it is an ADP database?
.. omg..
Is this because it is an ADP database? possibly
use ADODB recordset not DAO.
Is this because it is an ADP database? possibly
use ADODB recordset not DAO.
ASKER
i then get the same error with this line haha
Set rs = CurrentDb.OpenRecordset(ss ql)
Set rs = CurrentDb.OpenRecordset(ss
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Then set the control sources of the textboxes to the fields in your query. If your query has 20 rows this should give you the appearance you want.