I'm sure this is down to Monday blues but...
I have a Form with a List Box on it. The Form is bound to a table called "Contacts". I have a Delete button on the Form as well. The idea is that when the user clicks onto a name in the list box, further details are displayed in the Form text boxes etc. This operation works. Its only when I start deleting records and then try and use the List Box do I encounter problems. I'm getting a "Record Deleted" message when I click on the entry in the ListBox that has now taken the place of the record I have just deleted. (I hope this makes sense).
The code behind the Delete button is:
Private Sub cmdDelete_Click()
Set MyRs = Me.RecordsetClone
Me.Bookmark = MyRs.Bookmark
MyRs.Delete
MyRs.Close
DoCmd.GoToRecord , "demo", acPrevious
MsgBox "Record is Deleted!!", 64, "No Turning Back!!"
List1.Requery
End Sub
The code behind the ListBox is:
Private Sub List1_Click()
Set DB = CurrentDb
Set MyRs = DB.OpenRecordset("Contacts", dbOpenDynaset)
strCriteria = "[ContactID]= " & (Me!List1) & ""
MyRs.FindFirst strCriteria
Forms!Demo.Bookmark = MyRs.Bookmark
MyRs.Close
End Sub
If however I open and close the Form it all seems to fall back into place nicely. Is this something to do with the Bookmarks and not re-setting them? Please expand...
I have a Form with a List Box on it. The Form is bound to a table called "Contacts". I have a Delete button on the Form as well. The idea is that when the user clicks onto a name in the list box, further details are displayed in the Form text boxes etc. This operation works. Its only when I start deleting records and then try and use the List Box do I encounter problems. I'm getting a "Record Deleted" message when I click on the entry in the ListBox that has now taken the place of the record I have just deleted. (I hope this makes sense).
The code behind the Delete button is:
Private Sub cmdDelete_Click()
Set MyRs = Me.RecordsetClone
Me.Bookmark = MyRs.Bookmark
MyRs.Delete
MyRs.Close
DoCmd.GoToRecord , "demo", acPrevious
MsgBox "Record is Deleted!!", 64, "No Turning Back!!"
List1.Requery
End Sub
The code behind the ListBox is:
Private Sub List1_Click()
Set DB = CurrentDb
Set MyRs = DB.OpenRecordset("Contacts", dbOpenDynaset)
strCriteria = "[ContactID]= " & (Me!List1) & ""
MyRs.FindFirst strCriteria
Forms!Demo.Bookmark = MyRs.Bookmark
MyRs.Close
End Sub
If however I open and close the Form it all seems to fall back into place nicely. Is this something to do with the Bookmarks and not re-setting them? Please expand...