OnClose Requery Question

BrittKnee

New Member
Joined
Dec 4, 2017
Messages
24
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
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
871
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.
 

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
871
Well, please post it for the benefit of others, as this question comes up a lot.?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,851
Messages
5,598,452
Members
414,240
Latest member
xnanx

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
Top