Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

MS Access - Form AfterUpdate - Need to reset Focus

Posted on 2009-04-11
7
940 Views
Last Modified: 2013-11-28
Hi-
I added column Updated_Date to my Company table.

On the AfterUpdate section of my form CompanyMain, I have this:
private sub form_afterupdate()
    Me.Updated_Date = Now()
end sub

But although it does time-stamp it doesn't give me focus back to work on another part of the form....
Any ideas?
Stacy
0
Comment
Question by:stacydr
  • 3
  • 3
7 Comments
 
LVL 5

Expert Comment

by:brandonvmoore
ID: 24124659
It sounds like you just need to add a line of code to manually set the focus wherever you need it.  But that's pretty obvious so I'm thinking that's probably not your problem.
0
 
LVL 2

Author Comment

by:stacydr
ID: 24127964
Hi-
I guess the problem is I'm not sure where the focus from the user will be next.
The Main Form is Company Main
within is three subforms:
CompanyDetail
ContactsDetail
ActivityMain (Which has it's own subreport ActivityDetail)
So a user could potentially go anywhere within the 5 noted forms..

right now: It's like the whole form just stops working...

I tried to add Me.SetFocus to the noted code but that didn't work.
So here I am..
Sorry I'm not better at this - I haven't used Access like this is a number of years and I keep confusing my languages, I probably shouldn't have started this project but here I am..
so thanks for any time your spending on helping me..Stacy
0
 
LVL 5

Expert Comment

by:brandonvmoore
ID: 24133375
OK, problems like these are 'usually' best solved by using an implementation that isn't dependent on focus.  If I knew exactly what you were trying to do maybe I could help with that.

When you are working with multiple forms each form has its own focus, but only one form is active at a time and you can programmatically activate a different form if you need to.  I don't remember exactly how this works with subforms because I haven't worked with subforms or Access in a long time, but if your setfocus statement isn't working then perhaps it's because the wrong form is currently active.  

Also, don't forget that code in a subform can access the parent form.  Of course, you will have to be careful about doing this if the subform is used in other forms.

If none of that helped or lead you in the right direction then post a little bit more detail on the big picture of what you're trying to do.
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 2

Author Comment

by:stacydr
ID: 24134036
Hi -
Thanks for helping..
What I'm trying to do is if a Company or Contact is updated, then I want to timestamp the Update_Date field.  But when I add this function in -- I can't move to another company or subform after I update the record.  And when I try to close the form -- I get an error that says I can't save the record at this time (even though it already timestamped the row)..
Stacy
0
 
LVL 5

Expert Comment

by:brandonvmoore
ID: 24134644
Is that all the error says or does it give any more detail as to why it can't close the form?

Have you tried programatically saving the record right after you add the timestamp?  Try doing this and if it still give you an error let me know what it is.

You might also try updating the table directly (ie. the way you would if it wasn't connected to the Recordset property and you couldn't use the "Me" keyword to access it).  If you do this and it works, you may have to call some function to refresh the screen so that the timestamp will show up on screen after you add it.
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 24135435
Stacy, Ive been thinking about this, I think it has to do with the time, seconds part that changed and so form changes again, it might be in a loop. Ive used things to update in the afterupdate event and not had a problem, mind you, I dont recall using time

Can you try this out on the beforeupdate event

private sub form_beforeupdate(cancel as integer)
    Me.Updated_Date = Now()
end sub

If you want it to update on specific field changes only then use the beforeupdate (or afterupdate) event of that individual control only and not the form level event.

This should still set your date
0
 
LVL 2

Author Closing Comment

by:stacydr
ID: 31569276
Thanks that seemed to do it!
Stacy
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ADODB problem 20 37
default combobox value 12 18
How open a file when clicking on a text field 7 19
Access Schema 6 24
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question