[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

MS Access - Form AfterUpdate - Need to reset Focus

Posted on 2009-04-11
7
Medium Priority
?
951 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
[X]
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
  • 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

650 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