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!

Store query results in unbound text box ?

Status
Not open for further replies.

pnsmack

Programmer
Feb 12, 2002
12
US
Good Afternoon,

I have a simple form with a primary key field "Employee ID" and other fields that need to be filled in.

What I'd like to do is create an unbound text box at the bottom of the form, and simply print the results of a query in that text box as the "Employee ID" value changes. The query is basically listing all of the rows already in the table for that employee i.d.....

Is there a way to do this ?

Thanks !
Paul
 
Dim db As DAO.Database
Dim rst As DAO.Recorset
Dim strSQL As String
Dim strValueOfQuery As String

strSQL = "SELECT * FROM tblEmployee WHERE EmpID='" & Me.txtEmpID & "';"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
If rst.RecordCount <> 0 Then
rst.MoveFirst
DoWhile Not rst.EOF
strValueOfQuery = strValueOfQuery & rst!FieldName
rst.MoveNext
Loop
End If
Me.txtValueOfQuery = strValueOfQuery

Set db = Nothing
Set rst = Nothing

Steve King

Growth follows a healthy professional curiosity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top