Unfortunately its more complicated than that.
A text box want a particular item or field not a recordset which is what a query is.
Dim Conn2 As ADODB.Connection
Dim Rs1 As ADODB.Recordset
Dim SQLCode As String
Set Conn2 = CurrentProject.Connection ' <<<<Note same as CurrentDb
Set Rs1 = New ADODB.Recordset
' SQLCode is where your Query statement will go such as below
SQLCode = "SELECT * FROM [yourTable] WHERE Yourfield = something;"
Rs1.Open SQLCode, Conn2, adOpenStatic, adLockOptimistic
'Then you can set the Texbox to any field in the query
Me![YourTextbox] = Rs1!AnyfieldInQueryStatement
' close it this way
Set Rs1 = Nothing
Set Conn2 = Nothing
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.