Refresh/Requery Form

Rosebud

Registered User.
Local time
Today, 14:06
Joined
Dec 5, 2000
Messages
28
Hello,

I have a problem that seems pretty simple but I just can't figure out. I am trying to requery a main form without losing the current record.

I have a form of students that shows basic info on these students. This form cannot be edited, but there is a button on the form that when clicked, takes you to a similar form that can be edited. When exiting this editable form, you go back to the main form. I want this main form to requery to show the changes made, however when it gets requeried, the record selector moves to the first record.
I don't believe bookmarking works after you requery a form, but if I'm wrong please let me know. Thanks.

Rosebud
 
Hello Rosebud. I had the same problem not long ago. Here's how I solved it. Perhaps you can adapt my solution to your problem. The field 'PartNum' is the primary key for my source table.

  • Private Sub cmdEditDetails_Click()
    Dim strItem As String
    strItem = Me.PartNum
    'Some code to update the data
    Me.Requery
    Me.RecordsetClone.FindFirst "[PartNum] = '" & strItem & "'"
    Me.Bookmark = Me.RecordsetClone.Bookmark
    End Sub

I hope this helps.

~Abby

[This message has been edited by Abby N (edited 04-10-2001).]
 
Thanks a bunch Abby, I tried your code and it worked great!

I do have one problem though. Suppose I edit the very last record on the main form. After editing this student and going back to the main form, now (after I added your code) the cursor makes that student the current student (which is what I want) but it moves him to the top of the list. With him being the last student, it looks kinda funny, like there's only one record and a buncha space beneath this record.

Do you have any idea to keep the screen appearance from changing?

Thanks,
Rosebud
 
Sorry, I've never been able to come up with a good solution for that one. I've had the code shift the focus back 5 or 10 records after the find and then move forward again. That works sometimes, but its not a great solution. So, if you find a good one let me know!

~Abby
 

Users who are viewing this thread

Back
Top Bottom