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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bookmarks!

Status
Not open for further replies.

rookery

Programmer
Apr 4, 2002
384
GB
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...
 
Add a requery to the list box after the delete action.

This will refresh the data in the list box and should eliminate the problem. Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Thanks for your reply Larry but I already have added a Requery of the ListBox after the Delete action. Any other ideas....?
 
If the list boxes data is based on the data of the form, you may need to requery the form also:

me.requery

....
 
Cheers Taber for your response. I've since got it to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top