OnClose Requery Question

BrittKnee

Board Regular
Joined
Dec 4, 2017
Messages
82
Hello! I have created a form in my database that allows a user to enter notes. This form is access through another form (Edit Client Data). I have an "Add Notes" button which opens the Notes form in a pop up menu. I have entered an OnClose Event using the Requery function to refresh a subform I have created to display all Client Notes. Upon closing the Notes Form, the Edi Client Data Form is displayed however it refreshes to the first record in my RecordSet and not the record it was previously on. For example:

Client ABCDEF is the first record in my record set. I have opened the Edit Client Data form for Client 12345. I click "Add Note" to add a note for Client 12345. Once I close/save the Notes Screen I am returned to the Edit Client Data Screen for Client ABCDEF rather than Client 12345.

I am using Access 2016.

I am pulling my hair out trying to figure out what is going on. Below is the code for the "Add Note" Save/Close function

Code:
Private Sub Command464_Click()

If IsNull(Me.cbo_ClientName) Then
    MsgBox "PLEASE ENTER CLIENT NAME", vbExclamation, "DATA REQUIRED!"
    Me.cbo_ClientName.SetFocus
Exit Sub
End If

If IsNull(Me.Text460) Then
    MsgBox "PLEASE ENTER DATE", vbExclamation, "DATA REQUIRED!"
    Me.Text460.SetFocus
Exit Sub
End If

If IsNull(Me.Text465) Then
    MsgBox "PLEASE ENTER CLIENT NOTES", vbExclamation, "DATA REQUIRED!"
    Me.Text465.SetFocus
Exit Sub
End If

DoCmd.Close
DoCmd.OpenForm "Master_ManAcc_Form_EDIT_Client_Data"
End Sub

Thanks!



Private Sub Form_Close()
Forms!Master_ManAcc_Form_EDIT_Client_Data.Requery
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
A Requery does just that, so you start with fresh data.
The normal process is to save the ID of the record, requery and then find the record again.
 
Upvote 0
Well, please post it for the benefit of others, as this question comes up a lot.?
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,428
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top