Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to show a record set value in a text box? 1

Status
Not open for further replies.

kosala1981

Programmer
Apr 10, 2007
17
LK
i want to display a value in a record set in a textbox .but it gave an error saying "You can't reference a property or method for a control unless the control has the focus"

here's my code : this is a Combo box click method.

Private Sub cmbIndicator_Click()--->Combo box

Dim rsRecordset As Recordset
Dim dbCurrent As Database

Dim sSql As String

sSql = "SELECT * FROM ComponentData WHERE ComponentData.nComponentId = ( SELECT nNumeratorCompId FROM Indicator WHERE tIndicatorName='" + Trim(cmbIndicator.Text) + "')"
Set dbCurrent = DBEngine.Workspaces(0).Databases(0)
Set rsRecordset = dbCurrent.OpenRecordset(sSql)

rsRecordset.MoveFirst
While Not rsRecordset.EOF

TextBox1.Text = rsRecordset.Fields("Criteria1").Value

rsRecordset.MoveNext
Wend

End Sub
 
Skip the .Text bit:

Trim(cmbIndicator)

You can have .Value, if you must.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top