Fill a Textbox with a query

M

mattia

Hi all, I've used comboboxes to retrieve data from a table, the code is
something like:
strSQL = "SELECT NomeProgetto, IDProgetto FROM
QueryVisualizzaProdottiProgetti WHERE IDProdotto = " & Me.cboProdotto &
";"
Me.cboProgetto.RowSource = strSQL
Me.cboProgetto.BoundColumn = 2

RowSource basically retrieve the data from the query and populate the
combobox. What if I want to do the same with a textbox? The rowsource
attribute is not provided in vba code.

Thanks, Mattia
 
D

Dale_Fye via AccessMonster.com

Well, since a textbox should only hold a single value, using a Select
statement is not generally the best way to do it. You could use a DLOOKUP( )
domain function to get the value from a particular field in a table, based on
some criteria. Be advised that if the criteria is left out, it will return
the value from the first record in the table or query.

HTH
Dale
 
M

mattia

Il Mon, 20 Jul 2009 20:24:32 +0000, Dale_Fye via AccessMonster.com ha
scritto:
Well, since a textbox should only hold a single value, using a Select
statement is not generally the best way to do it. You could use a
DLOOKUP( ) domain function to get the value from a particular field in a
table, based on some criteria. Be advised that if the criteria is left
out, it will return the value from the first record in the table or
query.

HTH
Dale

Perfect, yeah obviously I'll have to provide a single value (although the
DLookup help tells me that DLookup always provide one return value),
thanks for the advice.
 
Top