PDA

View Full Version : Solved: SQL and Textboxes



icthus123
07-13-2007, 07:41 AM
I think this is probably an obvious question. But how to I populate i textbox with the results of an SQL Query rather than a combo box?

Ebrow
07-13-2007, 11:28 AM
Sub test()

Dim mySQL As String
Dim rs As Recordset

mySQL = ""
mySQL = mySQL & "SELECT tblTest.TestField "
mySQL = mySQL & "FROM tblTest;"

Set rs = CurrentDb.OpenRecordset(mySQL)

textbox1.Value = rs![testfield]


End Sub

icthus123
07-16-2007, 01:37 AM
Sub test()

Dim mySQL As String
Dim rs As Recordset

mySQL = ""
mySQL = mySQL & "SELECT tblTest.TestField "
mySQL = mySQL & "FROM tblTest;"

Set rs = CurrentDb.OpenRecordset(mySQL)

textbox1.Value = rs![testfield]


End Sub


Thanks a lot ebrow! Works fine!