Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-30-2019, 01:01 PM   #1
mcescher
Busy as usual
 
Join Date: Mar 2018
Location: Midwest United States
Posts: 28
Thanks: 11
Thanked 3 Times in 3 Posts
mcescher is on a distinguished road
Me.Refresh causes error

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?

mcescher is offline   Reply With Quote
Old 09-30-2019, 02:12 PM   #2
isladogs
High Noon Moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 11,287
Thanks: 115
Thanked 3,089 Times in 2,807 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
Re: Me.Refresh causes error

What is the name of that text field?
Does it contain a space or special character such as % or /
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Colin (Mendip Data Systems)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Common sense and a sense of humour are the same thing, moving at different speeds. (Clive James - RIP)
isladogs is offline   Reply With Quote
The Following User Says Thank You to isladogs For This Useful Post:
mcescher (10-01-2019)
Old 09-30-2019, 03:24 PM   #3
missinglinq
AWF VIP
 
missinglinq's Avatar
 
Join Date: Jun 2003
Location: Richmond (Virginia that is!)
Posts: 6,319
Thanks: 11
Thanked 721 Times in 671 Posts
missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light
Re: Me.Refresh causes error

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)>

__________________
The Devil's in the Details!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


(All code solutions tested in Access 2003/2007, before posting, unless otherwise noted.)
missinglinq is offline   Reply With Quote
The Following User Says Thank You to missinglinq For This Useful Post:
mcescher (10-01-2019)
Old 09-30-2019, 07:46 PM   #4
JHB
Have been here a while
 
Join Date: Jun 2012
Location: In the south of Denmark (Jutland), near the German border.
Posts: 7,720
Thanks: 3
Thanked 2,082 Times in 2,037 Posts
JHB has a spectacular aura about JHB has a spectacular aura about
Re: Me.Refresh causes error

Post a printscreen of the error and the actually code, or post your database with some sample data + description to reproduce the error.
__________________
If the above post has helped you, why not take the time to say thank you, by pressing the "Thumbs up."
JHB is offline   Reply With Quote
The Following User Says Thank You to JHB For This Useful Post:
mcescher (10-01-2019)
Old 10-01-2019, 04:28 AM   #5
mcescher
Busy as usual
 
Join Date: Mar 2018
Location: Midwest United States
Posts: 28
Thanks: 11
Thanked 3 Times in 3 Posts
mcescher is on a distinguished road
Re: Me.Refresh causes 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.

Thanks to everyone for you responses,
Chris
mcescher is offline   Reply With Quote
Old 10-01-2019, 09:45 AM   #6
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,311
Thanks: 15
Thanked 1,599 Times in 1,519 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: Me.Refresh causes error

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.
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 10-01-2019, 10:32 AM   #7
mcescher
Busy as usual
 
Join Date: Mar 2018
Location: Midwest United States
Posts: 28
Thanks: 11
Thanked 3 Times in 3 Posts
mcescher is on a distinguished road
Re: Me.Refresh causes error

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


mcescher is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error 3022 on Form Refresh Cheesewoman Forms 8 12-02-2014 12:43 AM
Error on Refresh Avizan05 Forms 1 05-27-2014 02:51 AM
Error excel refresh from access goyal Queries 0 06-10-2009 08:57 AM
Error on subform refresh Dmitriy Forms 3 05-19-2008 09:18 AM
Form Refresh Error illy2k Modules & VBA 3 07-05-2005 06:49 PM




All times are GMT -8. The time now is 01:07 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World