Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Access 2010 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2010 Programmer's Reference by Teresa Hennig, Rob Cooper, Geoffrey L. Griffith, Jerry Dennison; ISBN: 978-0-470-59166-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2010 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 25th, 2013, 12:24 PM
Registered User
Points: 25, Level: 1
Points: 25, Level: 1 Points: 25, Level: 1 Points: 25, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Posts: 6
Thanks: 3
Thanked 1 Time in 1 Post
Default TempVars

Hi All.
I'm having difficulties using TempVars. I can get them to work only with a click event. I need them to set with an OnChange event or similar. I've tried VBA and Macros both. Any suggestions would be appreciated.
Reply With Quote
  #2 (permalink)  
Old May 25th, 2013, 03:22 PM
gjgriffith's Avatar
Wrox Author
Points: 517, Level: 8
Points: 517, Level: 8 Points: 517, Level: 8 Points: 517, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 110
Thanks: 5
Thanked 14 Times in 14 Posts
Default Can you post the code you are having problems with?

Hello PoolMd,

Thank you for posting your question here. Specifically, you asked "I'm having difficulties using TempVars...I need them to set with an OnChange event or similar. I've tried VBA and Macros both." I'm wondering, can you post the code that is failing for you? I'd be more than happy to take a look!

Best Regards,
__________________
Geoffrey L. Griffith
http://www.ImagineThought.com

Wrox Author of:
Microsoft Access 2010 24-Hour Trainer
Access 2010 Programmer's Reference
Access 2007 VBA Programmer's Reference

*** Please click the THANKS button (to the right) if this post helped you! *** ---------------------------------------------------------------------------------------------------------->
Reply With Quote
  #3 (permalink)  
Old May 25th, 2013, 06:55 PM
Registered User
Points: 25, Level: 1
Points: 25, Level: 1 Points: 25, Level: 1 Points: 25, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Posts: 6
Thanks: 3
Thanked 1 Time in 1 Post
Default TempVars

I may not should have asked my question on this Forum. I am trying to run a macro as the book mentions on pages 76-77

Code:
Private Sub Form_AfterUpdate()
DoCmd.RunMacro "BookMacros"
End Sub
The Macro I created, "BookMacros", works fine when it is run from a Buttons On Click event. I'm wanting to run it whenever a field changes on my form. I've tried the above code from the Forms events properties as well as the fields After Update and On Change Field properties. I've also tried using the Embedded Macro feature and selecting it from the drop-down list of Macros
Thanks,
Reply With Quote
  #4 (permalink)  
Old May 26th, 2013, 08:04 AM
gjgriffith's Avatar
Wrox Author
Points: 517, Level: 8
Points: 517, Level: 8 Points: 517, Level: 8 Points: 517, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 110
Thanks: 5
Thanked 14 Times in 14 Posts
Default What error message do you receive when you use the AfterUpdate event for the control?

Hello PoolMd,

Thank you for the response to my previous message and for reading the "Access 2010 Programmer's Reference" book, we really appreciate your readership. You have definitely found the right forum for this question!

So, I reviewed the code you provided here, as well as pages 76-77 in the book. It looks like the code you've provided here runs your macro, called "BookMacros", on the "AfterUpdate" event for the form. And you also said: "I'm wanting to run (the macro) whenever a field changes on my form. I've tried the above code from the Forms events properties as well as the fields After Update and On Change Field properties." So, I will say that the problem sounds strange...

Really, in this situation, you should be able to place the "RunMacro" code behind the "AfterUpdate" event of the SPECIFIC CONTROL on the form for the data field. So, for example, if you have a "First Name" TextBox control on your form, then you should create an "AfterUpdate" event for the "First Name" TextBox control to run your macro. Does this make sense and have you tried this specifically? I realize that your message above says "as well as the fields After Update and On Change Field properties," but this would be the correct way to handle the situation as far as I can tell.

One other thing that I might mention is that for this code to run correctly, you MUST enable code in the database. I'm assuming that you know this already, but just in case, this can be accomplished by clicking the "Enable" button on the yellow "Security Warning" bar that is found just below the Ribbon when a database IS NOT already trusted.

So, if you're still having a problem here, I have created an example that shows exactly how to apply a macro using the method you are requesting here, which you can download from:

http://www.ImagineThought.net/c/Exam...13-26-05.accdb

Also, another thing I would mention in regard to this question. I noticed that you are using VBA code on the "After Update" event to simply call "DoCmd.RunMacro" and it looks like that is it. I'm assuming that you ONLY want to run a macro on the "After Update" event (and not run other VBA code along with the macro). So, instead of placing a VBA Code event behind the form to call "RunMacro", you could just choose the "Macro Builder" option to simply create a new macro to run on the event. And, if you already have the macro created (as an Access "Macro" Object that you can see in the Navigation Pane), you can just select that Macro by its name for the "After Update" field in the Property Sheet when the TextBox control is selected, and it will run automatically - you don't really need the VBA code here. So that would be a simpler option for what you want to do here, because it eliminates the VBA code to call the "RunMacro" function. But really, either option should work the same way - that is one of the beauties of Access - you have lots of different options for accomplishing the same task!

So, anyway, I hope this is helpful. If you are still having problems, or have any more questions in this area, please feel free to reply here and I will do my best to help out!

Best Regards,
__________________
Geoffrey L. Griffith
http://www.ImagineThought.com

Wrox Author of:
Microsoft Access 2010 24-Hour Trainer
Access 2010 Programmer's Reference
Access 2007 VBA Programmer's Reference

*** Please click the THANKS button (to the right) if this post helped you! *** ---------------------------------------------------------------------------------------------------------->

Last edited by gjgriffith; May 27th, 2013 at 12:45 PM..
Reply With Quote
The Following User Says Thank You to gjgriffith For This Useful Post:
poolmd (May 27th, 2013)
  #5 (permalink)  
Old May 27th, 2013, 08:33 AM
Registered User
Points: 25, Level: 1
Points: 25, Level: 1 Points: 25, Level: 1 Points: 25, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Posts: 6
Thanks: 3
Thanked 1 Time in 1 Post
Default TempVars - Resolved

Thank You gjgriffith,

You have been a big help. As you can see I am still learning. My problem was thinking that the events could be triggered when a record changes. After analyzing what I'm trying to accomplish, this isn't necessary anyway. Your post suggestions along with your example corrected my process and understanding.

I would like to say thank you to you and your fellow Authors of Access 2010 Programmer's Reference. I am learning a lot from it, and appreciated some of the code examples like the Record Finder and Report Viewer to name a few. I have incorporated these in a couple of my applications.
Thanks Again
Reply With Quote
The Following User Says Thank You to poolmd For This Useful Post:
gjgriffith (May 27th, 2013)
  #6 (permalink)  
Old May 27th, 2013, 12:32 PM
gjgriffith's Avatar
Wrox Author
Points: 517, Level: 8
Points: 517, Level: 8 Points: 517, Level: 8 Points: 517, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 110
Thanks: 5
Thanked 14 Times in 14 Posts
Default Glad to hear you got it worked out!

Hello PoolMd,

Thank you so much for the follow up message, I'm so glad to hear that you've got this problem worked out now. Also, thank you very much for the kind words about me and the book, we really appreciate your readership and are glad to hear that it is helping you. If there is anything else we can do in the future, please just to let us know!

Thanks again,
__________________
Geoffrey L. Griffith
http://www.ImagineThought.com

Wrox Author of:
Microsoft Access 2010 24-Hour Trainer
Access 2010 Programmer's Reference
Access 2007 VBA Programmer's Reference

*** Please click the THANKS button (to the right) if this post helped you! *** ---------------------------------------------------------------------------------------------------------->
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off




All times are GMT -4. The time now is 07:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.