Edward Zuris
edzedz at comcast.net
Fri Jan 29 10:08:35 CST 2010
Thanks Drew. I have some API experience, but no where close to being an expert in it. Luckily I have the ability to get to the original Vba code. Yes please, I would like to see your API code. Thanks. Sincerely, Ed Zuris. -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Drew Wutka Sent: Thursday, January 28, 2010 3:39 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] In a legacy system how control a Vba MsgBox Hmmmm, this is a little trickier then I think some of the replies have posted. You said you are automating this, which means that you are using your own code to open a form. And that form goes and opens a msgbox at some point. The problem is, that when you open a form, and cause the msgbox to be opened, that messagebox is going to be modal, so that the calling code will freeze. Let's say that the msgbox appears when the form initially opens, what you will find, is that your code is going to never get to the next line, until the msgbox is responded too. If the msgbox appears when a textbox value is set, then your code will freeze at the point where you set the text value, etc. There are three solutions that I know of: 1. Modify the original code, so that it presents a form, instead of a msgbox, so that it can be opened and responded to non-modally. 2. Modify the original code, so that the it accepts a value from a msgbox that your own code prompts with. 3. (This one is a bit more involved and trickier, and should only be used if you can't modify the original code (like it's in an mde)). You need to have a separate thread watch for the msgbox and react to it. This can be done with a multithreaded app (which you can't do in VBA, you can do this in VB 6 or .NET), or create a separate app that your program kicks off, which monitors for the msgbox. Either way, to do this, can 'detect' the msgbox as being a child window of the Access window, it'll have a specific class/title. I have some code lying around that may be useful, holler if you want it. If you don't have a lot of experience with window API's, it might be a little confusing at first.... Drew -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Edward Zuris Sent: Thursday, January 28, 2010 1:40 PM To: accessd at databaseadvisors.com Subject: [AccessD] In a legacy system how control a Vba MsgBox Dear AccessD Forum I am doing a little automation work within a legacy environment. From inside some VBA code, a form is opened, given some data, where buttons and controls are clicked. The opened form, ft001CreateTasks, has a MsgBox asking a Yes/No question. What kind of handle do I use to click the YES button on the message box modal form ? Or are there some other way of tackling this issue ? Thanks. Sincerely, Ed Zuris. ==================================================== Example Vba Code snippet ==================================================== strVar = "" DoCmd.OpenForm "ft001CreateTasks", , , strVar strVar = "Rake Yard" Forms("ft001CreateTasks").cboTaskType.Value = strVar Call Forms("ft001CreateTasks").cboTaskType_Click . . . . now a message box open on the form . . . . . ==================================================== ==================================================== -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com