Me.Refresh causes error

mcescher

Busy as usual
Local time
Today, 16:09
Joined
Mar 19, 2018
Messages
28
Hi All,
Kind of a strange question.

I have a form with 10 text boxes that the user will fill in and the last two will do calculations based on the information that they entered.

So, I've added code like this for each of the entry text boxes

Code:
Private Sub txtField1_AfterUpdate()
    Me.Refresh
End Sub

That way if the user goes back to Field1 and changes the entry, the answers will update. I am checking for empty fields and those are all fine.

My problem is that one of the text fields gives me an error:

Database can't find the object 'Me.'
If 'Me' is a new macro or macro group, make sure you have saved it and that you have typed its name correctly.

But only that specific text box. Doesn't matter if they're all empty or all filled.

All the rest of the text boxes are fine. They update and don't give an error message.

What's up?
 
What is the name of that text field?
Does it contain a space or special character such as % or /
 
Have no idea why Access would balk and give that kind of error with

Me.Refresh

That error usually pops when you try to use Me. in the Control Source Property of a Control.

If your concern is having a calculated field be re-calculated, when one of the component fields is changed, you really should be using

Me.ReCalc

instead. Why don't you try that?

Linq ;0)>
 
Post a printscreen of the error and the actually code, or post your database with some sample data + description to reproduce the error.
 
Found it... Sometimes it's the silly mistakes.

While I was clicking in the Properties window in Access to add the "_AfterUpdate" link, I accidentally hit Ctrl V in that box. So instead of

"[Event Procedure]"

It said

"Me.Refresh[Event Procedure]"

And Access didn't like that. :banghead::rolleyes:

Thanks to everyone for you responses,
Chris
 
Me.Refresh forces the current record to be saved before it refreshes the recordset. Therefore, it should NOT be used mid process because you end up saving incomplete records. If you have validation in the form's BeforeUpdate event (which you should), it will be executed prematurely and raise errors when it shouldn't.

Calculated values should not be stored. Do this calculation in the query and it will refresh automatically if any component field changes. If you insist on saving the calculated value (you should not. It is poor practice and leads to data anomalies), at least use the BeforeUpdate event which doesn't run until the record is being saved so all values should actually be present.
 
Yup, know all that. This is a disconnected recordset, and not storing the values. Just a simple calculator for the user to know how much material to order. They take that and make choices in another form.

Thanks,
Chris
 

Users who are viewing this thread

Back
Top Bottom