i have created textboxes for each fields available in an existing database file in a vb form.i need to show the data in the textboxes whenever i click the command buttons next and previous.help needed
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "datasource=E:\project1\databmdb;"
cn.Open//shows error here
str = "Select * from table"
rs.Open str, cn
Set Text1.DataSource = rs
Text1.DataField = "NAME"
end sub
Personally I prefer not to bind the text boxes to a datasource. Typically I will use an array of text boxes and populate them in a loop
for example if there are 10 fields in the RS and an array of 10 textboxes to be populated the code may look somethign like.
Code:
For x=0 to 9
TextBox1(x).text=RS(x)
Next
Using this method the text box is not bound to the database so any changes to the data in the boxes do not have any effect on the database unless you write code to do so in your save routine. Basically the opposite of what is above
Bookmarks