Paulsburbon
Registered User.
- Local time
- Yesterday, 17:43
- Joined
- May 3, 2005
- Messages
- 65
I tried to figure out something and need some help. I forgot when I started on this database a field to sort Products on. So I added a field intSort to the table and was hoping to have the user press a button to order the list of Items on a subform by twos. That way when they add an Item they could type in 5 and get it to be inbetween 4 and 6. Then when they hit the button again it would resort. My code is not doing what I would like it to do though. It is just adding up the records in the group and putting it in the second record in the group. Here is my code:
Private Sub Toggle97_Click()
On Error GoTo Toggle97_Click_Err
Dim Count As Integer
Dim intAnswer As Integer
Dim rsProductItems As New ADODB.Recordset
Dim strSQLStmt As String
intAnswer = MsgBox("This will sort the current Items on this Claim. Do you wish to proceed?", vbQuestion + vbYesNo, "Sort Items")
If intAnswer = vbYes Then
strSQLStmt = "SELECT * FROM tblClaimLineItems WHERE tblClaimLineItems.[lngClaimNumber] = '" & Me.TXTClaimNumber & "';"
rsProductItems.Open strSQLStmt, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
Count = 2
Do Until rsProductItems.EOF
Text95.Value = Count
Count = Count + 2
rsProductItems.MoveNext
Loop
End If
Exit Sub
Toggle97_Click_Err:
MsgBox "Error is " & Err.Description
Exit Sub
End Sub
What am I doing wrong? I havn't even attempted sorting the records yet. Thank you for your help.
Paul
Private Sub Toggle97_Click()
On Error GoTo Toggle97_Click_Err
Dim Count As Integer
Dim intAnswer As Integer
Dim rsProductItems As New ADODB.Recordset
Dim strSQLStmt As String
intAnswer = MsgBox("This will sort the current Items on this Claim. Do you wish to proceed?", vbQuestion + vbYesNo, "Sort Items")
If intAnswer = vbYes Then
strSQLStmt = "SELECT * FROM tblClaimLineItems WHERE tblClaimLineItems.[lngClaimNumber] = '" & Me.TXTClaimNumber & "';"
rsProductItems.Open strSQLStmt, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
Count = 2
Do Until rsProductItems.EOF
Text95.Value = Count
Count = Count + 2
rsProductItems.MoveNext
Loop
End If
Exit Sub
Toggle97_Click_Err:
MsgBox "Error is " & Err.Description
Exit Sub
End Sub
What am I doing wrong? I havn't even attempted sorting the records yet. Thank you for your help.
Paul