Saturday, February 25, 2012

ADODB to textBox

First time poster, I am using MS Access and I have used the following code to get some data. It is as follows:

Code Snippet

Private Sub FillGUI()
On Error Resume Next

Dim myRS2 As New ADODB.Recordset

myRS2.ActiveConnection = CurrentProject.Connection
myRS2.CursorType = adOpenDynamic
myRS2.LockType = adLockOptimisticd
myRS2.Open "SELECT E.SSN, E.LNAME, SUM(W.HOURS) FROM EMPLOYEE E, WORKS_ON W WHERE (E.SSN = W.ESSN)GROUP BY E.SSN, E.LNAME HAVING(SUM(HOURS)) < 40"

MsgBox (myRS2.GetString)
myRS2.MoveFirst

End Sub

and I have the following output:

http://www.angelfire.com/oh5/ohiostate120/untitled1.JPG

This is what I want. However I need this to be in a text box so I have the following code:

Code Snippet

Private Sub FillGUI()
On Error Resume Next

Dim myRS2 As New ADODB.Recordset

myRS2.ActiveConnection = CurrentProject.Connection
myRS2.CursorType = adOpenDynamic
myRS2.LockType = adLockOptimisticd
myRS2.Open "SELECT E.SSN, E.LNAME, SUM(W.HOURS) FROM EMPLOYEE E, WORKS_ON W WHERE (E.SSN = W.ESSN)GROUP BY E.SSN, E.LNAME HAVING(SUM(HOURS)) < 40"

Me.txtEmployee.SetFocus
Me.txtEmployee.Text = myRS2.GetString
myRS2.MoveFirst

End Sub

And i get this:

http://www.angelfire.com/oh5/ohiostate120/untitled2.JPG

How can I get the text box format to look like the msgbox format? Thanks.........

This is not an SSIS question.

You might try asking in the "Where is the forum for...?" forum to see if someone there can direct you to the correct place to ask your Access question.

Forum: http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=881&SiteID=1

Thanks,
Phil Brammer|||Yeah I thought I put it in the wrong place. Thanks

No comments:

Post a Comment