Dim mobjCN As ADODB.Connection Dim mobjRS As ADODB.Recordset5. Create a sub to fill controls from your recordset
Private Sub FillControls() Text1.Text = mobjRS.Fields(0).Value Text2.Text = mobjRS.Fields(1).Value End Sub6. Add this code to the Form_Load event to connect to the database, retreive some data and fill textboxes
Private Sub Form_Load() Set mobjCN = New ADODB.Connection With mobjCN .CursorLocation = adUseClient .ConnectionString = "Provider=sqloledb;" & _ "Data Source=(local);" & _ "Initial Catalog=Pubs;" & _ "Integrated Security=SSPI" .Open End With Set mobjRS = New ADODB.Recordset With mobjRS .CursorLocation = adUseClient .CursorType = adOpenStatic .LockType = adLockReadOnly .Open "SELECT * FROM Authors", mobjCN End With FillControls End Sub7. Add this code to do a "previous" button
Private Sub Command1_Click() mobjRS.MovePrevious If mobjRS.BOF Then mobjRS.MoveFirst FillControls End Sub8. Add this code to do a "next" button
Private Sub Command2_Click() mobjRS.MoveNext If mobjRS.EOF Then mobjRS.MoveLast FillControls End SubThat's it. It should be working now (if you have a Pubs database and a Authors table)!