1 Replies - 6122 Views - Last Post: 10 October 2007 - 05:18 AM Rate Topic: -----

#1 pietervdl  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 09-October 07

Return A Value from database to a textbox

Post icon  Posted 09 October 2007 - 11:18 PM

I its me again, in the following code, I need a value returned from the database(SQL) into a text box.
Please help me.
Thanks
Private Sub DisplayBlackListInfo()

	Dim rsBlackList As ADODB.Recordset
	Dim rsReason As ADODB.Recordset
	Dim Reason As String
	Dim isBlacklisted As Boolean

		Set rsBlackList = New ADODB.Recordset
		Set rsReason = New ADODB.Recordset

		rsBlackList.Open "Select * From Residents Where [Id Number] = '" & txtIDNumber.Text & "'", cn, adOpenForwardOnly

		'rsReason.Open "SELECT Reason FROM tbl_BLackListReasons WHERE IDNumber = '" & txtIdnumber.Text & "'", cn, adOpenForwardOnly

		isBlacklisted = rsBlackList!Blacklisted
		

		lblListReason.Visible = True
		txtListReason.Visible = True

		lblListed.Visible = True
		chkListed.Visible = True

	 If rsBlackList.EOF = True Then
	 
			isBlacklisted = True
			rsReason.Open "SELECT Reason FROM tbl_BLackListReasons WHERE IDNumber = '" & txtIDNumber.Text & "'", cn, adOpenForwardOnly
			txtListReason.Text = rsReason!Reason
		   ' Reason = rsReason!Reason
			rsBlackList.Close
			rsReason.Close

	End If

		Set rsBlackList = Nothing
		Set rsReason = Nothing

End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: Return A Value from database to a textbox

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Return A Value from database to a textbox

Posted 10 October 2007 - 05:18 AM

To do that you just need TextBox1.Text = YourRecordSet("ColumnName"), of course replace TextBox1 with the name of your textbox and YourRecordSet("ColumnName") with your actual names.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1