Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

will not .MovePrevious() or .MoveLast()

Status
Not open for further replies.

callsupport1

Programmer
Jul 20, 2009
4
GB
Hi Experts please help

I am new to trying to program so please be gentle.

I am using vb2005 and can't use moveprvious or move last but can us movenext and movefirst.

Here is my code, don't laugh to much.

Public Class Form1
Dim MyConnObj As New ADODB.Connection 'ADODB Connection Object
Dim myRecSet As New ADODB.Recordset 'Recordset Object
Dim sqlStr As String ' String variable to store sql command
Dim c As String
Dim tot As Long
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyConnObj.Open( _
"Provider = sqloledb;" & _
"Data Source=LINK-2927;" & _
"Initial Catalog=Sage200_DemoData;" & _
"User ID=sa;" & _
"Password=link12?;")
sqlStr = "select * from SLCustomerAccount"
myRecSet.Open(sqlStr, MyConnObj)
TextBox1.Text = "" & myRecSet.Fields!CustomerAccountName.Value
TextBox2.Text = "" & myRecSet.Fields!CustomerAccountNumber.Value
myRecSet.MoveFirst()
End Sub
Private Sub NextButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextButton.Click
With myRecSet
.MoveNext()
If .EOF() = False Then
TextBox1.Text = "" & myRecSet.Fields!CustomerAccountName.Value
TextBox2.Text = "" & myRecSet.Fields!CustomerAccountNumber.Value
Else
.MoveFirst()
TextBox1.Text = "" & myRecSet.Fields!CustomerAccountName.Value
TextBox2.Text = "" & myRecSet.Fields!CustomerAccountNumber.Value
End If
End With
End Sub
Private Sub LastButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LastButton.Click
Try
With myRecSet
.MoveLast()
If .EOF() = False Then
TextBox1.Text = "" & myRecSet.Fields!CustomerAccountName.Value
TextBox2.Text = "" & myRecSet.Fields!CustomerAccountNumber.Value
Else
.MoveLast()
TextBox1.Text = "" & myRecSet.Fields!CustomerAccountName.Value
TextBox2.Text = "" & myRecSet.Fields!CustomerAccountNumber.Value
End If
End With
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub previousButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles previousButton.Click
With myRecSet
.MovePrevious()
If .EOF() = False Then
TextBox1.Text = "" & myRecSet.Fields!CustomerAccountName.Value
TextBox2.Text = "" & myRecSet.Fields!CustomerAccountNumber.Value
Else
.MoveFirst()
TextBox1.Text = "" & myRecSet.Fields!CustomerAccountName.Value
TextBox2.Text = "" & myRecSet.Fields!CustomerAccountNumber.Value
End If
End With
End Sub

Private Sub FirstButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FirstButton.Click
With myRecSet
.MoveFirst()
If .BOF() = False Then
TextBox1.Text = "" & myRecSet.Fields!CustomerAccountName.Value
TextBox2.Text = "" & myRecSet.Fields!CustomerAccountNumber.Value
Else
.MoveFirst()
TextBox1.Text = "" & myRecSet.Fields!CustomerAccountName.Value
TextBox2.Text = "" & myRecSet.Fields!CustomerAccountNumber.Value
End If
End With
End Sub
End Class


Thanks
Stephen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top