Refresh/OnCurrent Questions

  • Thread starter Thread starter Melissa
  • Start date Start date
M

Melissa

According to Access Help, Form.Current Event "Occurs when the focus moves to
a record, making it the current record, or when the form is refreshed or
requeried."

My understanding from this statement is that if I put code in my forms
OnCurrent property, then it should run everytime I Refresh the data, correct?
I believe that is exactly what I've been doing, but it doesn't work for some
of the code I have written in the OnCurrent property. Am I doing something
wrong?

Here's how my form works. I have a subform (e.g. SubFormA and SubFormB as
part of MainForm). The AfterInsert event of SubFormA has the code
Forms!frmMainForm.Refresh
The OnCurrent event of MainForm has the code
Me.SubFormB.Form!Field1.Locked = True
Me.SubFormB.Form!Field2.Locked = True

In my form, the fields in SubFormB are not locking after I've inserted a new
record in SubFormA. The reason I believe that the refresh code is working is
because some data I input in SubFormA is used to update data on the main
form, and once the AfterInsert event is triggered, this data is updated.
Additionally, Field1 and Field2 lock if I go to a different record and come
back but not when I simply refresh the data. Is there a better way to handle
this situation?
 
Melissa,
I don't believe it happens when you Refresh, but when you Requery the form.
Give that a try instead.
 
I don't believe it happens when you Refresh, but when you Requery the form.
Give that a try instead.

And it sounds like you are trying to see new records after an insert.
Refresh only refreshes the data for records that are already in your
recordset - it won't add new ones.

Requery completely rebuilds the recordset for the form, including new
records.

Hope this helps,

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
I'll try the requery, but no I'm not really trying to refresh the data. In a
nutshell, once a change the "Status" in a combo box field from "New" to
"Submitted", I want my whole form to lock so that the user can't add anything
else, and this includes the subform. Thanks for the advice.
 
Back
Top