Populate textbox from table

cynapattery

Registered User.
Local time
Today, 13:56
Joined
Jul 9, 2013
Messages
28
How to automatically populate the bound text box with data from a table for a specific entry.

this is the code I wrote

Private Sub ListBox_DblClick(Cancel As Integer)
Dim ListBoxSel As String
ListBoxSel = Me.ListBox.Value

Call proc_Update_TxtBoxes(Me.ListBox.Value)

DoCmd.Close
End Sub

Private Sub proc_Update_TxtBoxes(ListBoxSel)
Dim db As Database
Dim rs1 As DAO.Recordset
Dim strsql As String
Set db = CurrentDb
MsgBox ListBoxSel
strsql = "Select Website from Handler_contact where Haendlername = " & ListBoxSel
Set db = CurrentDb
Set rs1 = db.OpenRecordset(strsql)
'how do I get the bound textboxes with data from database?
Set rs1 = Nothing
rs1.Close

End Sub



Please help
 
Code:
.
.
strsql = "Select [B]Website[/B] from Handler_contact where Haendlername = '" & ListBoxSel & "'"
Set rs1 = db.OpenRecordset(strsql)
'how do I get the bound textboxes with data from database?

[B]Me![TextboxName] = rst1![Website]
[/B]
rs1.Close
Set rs1 = Nothing
.
.
 
I don't know where you're going with this. A bound control can hold only a SINGLE value. Are you expecting to populate it with multiple rows from the query? Why can't you use a subform to show the many-side data?
 
In first form, I have bounded text boxes (around 30 data fields to be populated) together with a button to search for a particular name.
When I click on this search button, a pop up window opens with a search text box and a list box. where the list box lists the whole name according to search text.
eg: if I type 'pay'
it displays all the names with contains pay.
this part works fine.
Now if I double click on paypal which is listed in this list box,
the whole data regarding paypal from database should be loaded in the previous window. where we had the search button. am I clear?
I am trying to realise with the help of recordset which was not sucessful.

I have saved the selected value in listbox into a string 'ListBoxSel'
-----------------
Set db = CurrentDb
strsql = ("Select * from Handler_contact where name=" & ListBoxSel)

Set rs1 = db.OpenRecordset(strsql)
Forms!frm_Trigger_Storno.Haendlername = rs1!name

Forms!frm_Trigger_Storno.Website = rs1!Website
-----------------

How should I correct the program to get it working?
I am using access 2010 is that a problem to get recordset not working?
I am just 1 month old in VB access programming.
Please help
 

Users who are viewing this thread

Back
Top Bottom