Link to home
Start Free TrialLog in
Avatar of CaptainGiblets
CaptainGibletsFlag for United Kingdom of Great Britain and Northern Ireland

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?
Avatar of mbizup
mbizup
Flag of Kazakhstan image

How about setting up a form in continuous forms view with 5 textboxes arranged touching each other horizontally, and space minimized between rows of the detail section.

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.
Avatar of CaptainGiblets

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("yourselectqueryname")

me.text1=rs.Fields(0)  ' or  me.text1=rs!NameOfField1
me.text2=rs.Fields(1)   ' or  me.text1=rs!NameOfField2


etc...
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 & "'"
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
Set rs = CurrentDb.OpenRecordset(ssql)
 
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.
i then get the same error with this line haha

Set rs = CurrentDb.OpenRecordset(ssql)
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial