I know this issue has been brought up here, and many times at that. However, I've read all the posts I could find on it and still can't solve my problem.
I have a subform built off a query, and when a user clicks the "remove" button next to a record, the record is deleted from the underlying table, and a .Requery is called. This part works just fine.
The problem is that my users don't want the subform to reset to the first record after removing an item from the list (which happens after the Requery). The list can be hundreds of items long, and thus very inconvienient if they have to scroll down again to remove the next item. Here is the code I have so far for the click event of my remove command button:
I've done some MsgBox debugging to make sure that curRecord is getting the right value, and even hardcoded in a value that I knew would exist, but I keep getting the error "You can't go to the specified record."
Anyone have any ideas how I can fix this? Thanks a ton in advance!
I have a subform built off a query, and when a user clicks the "remove" button next to a record, the record is deleted from the underlying table, and a .Requery is called. This part works just fine.
The problem is that my users don't want the subform to reset to the first record after removing an item from the list (which happens after the Requery). The list can be hundreds of items long, and thus very inconvienient if they have to scroll down again to remove the next item. Here is the code I have so far for the click event of my remove command button:
Code:
Private Sub cmdRemove_Click()
On Error GoTo Err_cmdRemove_Click
Dim strSQL As String
Dim curRecord As String
[green]' Delete all records in linktblThumbnailList[/green]
strSQL = "DELETE tbl_FiscalGraphList.*" & _
"FROM tbl_FiscalGraphList " & _
"WHERE (((tbl_FiscalGraphList.Item)=""" & Me.[Item] & """));"
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
curRecord = Me.CurrentRecord
Me.Requery
Me.Parent.SetFocus
If curRecord <> 1 Then
DoCmd.GoToRecord acDataForm, Me.Parent.Name, acGoTo, curRecord
End If
Exit_cmdRemove_Click:
Exit Sub
Err_cmdRemove_Click:
MsgBox Err.Description
Resume Exit_cmdRemove_Click
End Sub
I've done some MsgBox debugging to make sure that curRecord is getting the right value, and even hardcoded in a value that I knew would exist, but I keep getting the error "You can't go to the specified record."
Anyone have any ideas how I can fix this? Thanks a ton in advance!