1 More Question, I Swear...Action Listener For Changing Recs

Challseus

Board Regular
Joined
Feb 5, 2003
Messages
141
Hi all, again...

Anyhow, is there some sort of Action Listener for when the user changes to another record. If the info they filled out is incorrect, or they left a field blank, I want to prompt an error message and then keep focus on that record until they make the neccessary corrections.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Re: 1 More Question, I Swear...Action Listener For Changing

Take a look inside the Access Help under Events and Events Properties Reference.

Unfortunately, it may not be obvious which you might want and my experience with finding the best event is limited. BeforeUpdate, AfterUpdate or OnUpdated may be the best options.

Oops, [edit] should be heading home about now. If you look at the properties for a given control, there is a tab for Events showing you all that are actually available for that specific control (many in the list above do not apply to all objects)

Mike
 
Upvote 0
Re: 1 More Question, I Swear...Action Listener For Changing

aarrrgh....getting so mad....**** Microsoft. How can they have an event for all items on a form, except the buttons that change reocrds. I cant even see them when in design view to put some code under them. Someone please help...I'm pulling my hair out (and I already have a receding hair line:)

Note to mdmilner: I checked all the properties under all the controls and I couldn't find any that fitted what I needed

Note to Russel Hauf: Check the validation rule property under which control. If it is something in a help file, I cannot as they were never installed and the CD install CD isn't around.
 
Upvote 0
Re: 1 More Question, I Swear...Action Listener For Changing

I was looking at this one and now think the Validation Rule property is the best route to go. A value you can throw into it is:

Is Not Null

Exactly like that, with spaces, but you put it in the underlying table that the form is based upon. I haven't checked whether the exact same property is available for a textbox but it probably is.

The only thing I noticed when using this is that I didn't get an error message even though I entered/exited the field until I attempted to preform an action based on the contents of that field (completely unrelated to your question)

You'll get an error message that must be fixed, but you won't get it until well after the user leaves the field. My experience with forms is limited, but I believe that you should be able to force the field to test it's validation rule based on an Event such as OnExit (Exit) although I haven't tested this.

The OnExit property help text says:
"The Exit event occurs just before a control loses the focus to another control on the same form. "

and

"The Enter and Exit events apply only to controls on a form, not controls on a report."

One other thing you can try is this.

From the Form Design mode, you can right-click a control and select properties. If you then go to the Event tab, it should give you the names of all the events that are applicable to this control at this time. It doesn't explain what they do/how they work/when they work - but it's still a clue.

Something else you can do is use the object browser from within VBA to look at the various properties associated to everything. Really this part is intended to show you how to do it in VBA, but it could still help.

I hope this moves you closer to your goal.

Mike
 
Upvote 0
Re: 1 More Question, I Swear...Action Listener For Changing

Funny how you should say that, becasue I am currently using the OnExit event function. My whole problem was what happens if the user clicks the button on the bottom to switch to another record. I needed a way to go back to that record if one of the fields was not found in its corresponding table.

Then, by chance, I ran across this function name CancelEvent which works perfectly. After the OnExit event occurs, if the field is not found, I just call the CancelEvent function so if the user had clicked one of those buttons that advances to the next record, it would just cancel it. I'm now having a problem with DLookup and dynamically using it, but I'll out line that in a post when I get back from work if I cant figure it out.

Much thanks to you and Russel for all your help. You 2 have taught me more than any class would have taught me in the same time frame.
 
Upvote 0

Forum statistics

Threads
1,221,544
Messages
6,160,431
Members
451,646
Latest member
mmix803

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