Populating a text box from a RecordSet
Hello, I need help
Im working on an ACCESS form and I am trying to populate a text box with 2 fields from a recordset. I am trying to use a "For Loop" to do this and its not writing all the records in the recordset to the text box. It only writes the first record. The ESSN is used for employee social security number which is getting entered by the user typing it into txtSSN.
Here is my code:
myRS2.ActiveConnection = CurrentProject.Connection
mySQL2 = "Select ESSN,PNO,HOURS From Works_On Where ESSN=" & txtSSN
myRS2.Open (mySQL2)
'Write employee project(s) and hours to text field
For empCounter = 0 To myRS2.EOF
txtWorkHrs = "Project" & myRS2("PNO") & "-" & myRS2("HOURS") & "Hours"
myRS2.MoveNext
Next
Can anyone here help me with this and show me the correct way of doing this? It would be greatly appreciated. This is for a project that Im working on for my class in College.
Thank you for your time.
Eric
|