Problem bringing up a form from VBA module
Author |
Message |
Frank D. Nicodem, Jr #1 / 6
|
 Problem bringing up a form from VBA module
I don't know if this is more of a form question, or a VBA question. But in any case, I have a VBA module, called by clicking a Command button on one form (we'll call it FormA). The VBA module processes a variety of records from my database, and because it may take a while, I want to inform the user of the progress it's making. So I created a little form (call it FormB) with a couple of informational fields, and in my VBA code (at various spots), when critical data changes, I want to "post" it to that form so the user can see the progress of the function. I thought I had it all created correctly, and when I click the button on FormA, I can certainly tell that the module is running. And sure enough, it *appears* that FormB is coming up, because the outline of the form appears, with the title bar visible... but nothing else on the form is visible. And it STAYS that way for the entire duration of the function, which ends by closing FormB (which happens entirely correctly). The problem, of course, is that I see none of my "progress information", since FormB never fully seems to come up. I'm calling the form from my VBA code as follows: DoCmd.OpenForm "Track Processing" At first, I thought that maybe I needed to "do something" on the form, so I even tried a SetFocus to the form immediately after this line: Forms![Track Processing].SetFocus No difference. So what do I need to do to make the form come up AND have the fields on it be visible? Oh, BTW, I can bring up the Debug window and manually enter that first line exactly as shown above (the OpenForm line), and the form comes up perfectly. So it's ONLY when calling it from my VBA Function that it doesn't. Any suggestions? ------------------------------ Frank D. Nicodem, Jr.
|
Sun, 17 Feb 2002 03:00:00 GMT |
|
 |
M.L. Sco Scofiel #2 / 6
|
 Problem bringing up a form from VBA module
Try a DoEvents right after you open the form and then in the loop right after every update to the form. I do this and it works great. Problem is that Access doesn't yield enough time to Windows to get the form updated. DoEvents makes Access yield. -- Sco M.L. "Sco" Scofield, MCT, MCP, MSS Useful Metric Conversion #3 of 19: 500 millinaries = 1 seminary
Quote: > I don't know if this is more of a form question, or a VBA question. But in > any case, I have a VBA module, called by clicking a Command button on one > form (we'll call it FormA). The VBA module processes a variety of records > from my database, and because it may take a while, I want to inform the user > of the progress it's making. > So I created a little form (call it FormB) with a couple of informational > fields, and in my VBA code (at various spots), when critical data changes, I > want to "post" it to that form so the user can see the progress of the > function. > I thought I had it all created correctly, and when I click the button on > FormA, I can certainly tell that the module is running. And sure enough, it > *appears* that FormB is coming up, because the outline of the form appears, > with the title bar visible... but nothing else on the form is visible. And > it STAYS that way for the entire duration of the function, which ends by > closing FormB (which happens entirely correctly). > The problem, of course, is that I see none of my "progress information", > since FormB never fully seems to come up. I'm calling the form from my VBA > code as follows: > DoCmd.OpenForm "Track Processing" > At first, I thought that maybe I needed to "do something" on the form, so I > even tried a SetFocus to the form immediately after this line: > Forms![Track Processing].SetFocus > No difference. So what do I need to do to make the form come up AND have > the fields on it be visible? > Oh, BTW, I can bring up the Debug window and manually enter that first line > exactly as shown above (the OpenForm line), and the form comes up perfectly. > So it's ONLY when calling it from my VBA Function that it doesn't. > Any suggestions? > ------------------------------ > Frank D. Nicodem, Jr.
|
Sun, 17 Feb 2002 03:00:00 GMT |
|
 |
Frank D. Nicodem, Jr #3 / 6
|
 Problem bringing up a form from VBA module
Quote: > Try a DoEvents right after you open the form and then in the loop right
after every update to the form. Well, I got really e{*filter*}d after I put a DoEvents immediately after the form Open, and the form came up OK!! But that was *all* that happened. Even with a DoEvents after *every* update to the form, all of the fields remain blank -- nothing appears to happen (except that the Function continues to run successfully). And based on your suggestion re: the DoEvents, I tried something else -- I put a breakpoint at the beginning of the Function, and then *single-stepped* through it. And the fields DID get updated, as they should!! So evidently it must be related to what you said, but there must be more to it. Because now I can get the form to display, but nothing updated in the fields. (Oh, and I know that the command syntax is OK, because I can cut the lines that update the fields, paste them into the Debug Windows, and execute them -- and the fields get updated correctly.) So any other suggestions as to what I might do to get the fields updated? And if it helps, I'm not using Text boxes, but Labels, since I am only really putting out informational messages, and don't want editable fields. So I'm setting the Caption property of the various labels, rather than putting text into a Text box. Don't know if that makes a difference, but thought I'd mention it. ------------------------------ Frank D. Nicodem, Jr.
|
Sun, 17 Feb 2002 03:00:00 GMT |
|
 |
M.L. Sco Scofiel #4 / 6
|
 Problem bringing up a form from VBA module
I do exactly what you described all the time. Set the caption of a label to the new data and a DoEvents. Works just fine in Acc2 and Acc97. Don't know what to tell you. As an experiment, you might try using locked text boxes, although I can't see this making a difference. -- Sco M.L. "Sco" Scofield, MCT, MCP, MSS Useful Metric Conversion #4 of 19: 2000 mockingbirds = two kilomockingbirds
Quote:
> > Try a DoEvents right after you open the form and then in the loop right > after every update to the form. > Well, I got really e{*filter*}d after I put a DoEvents immediately after the form > Open, and the form came up OK!! But that was *all* that happened. Even > with a DoEvents after *every* update to the form, all of the fields remain > blank -- nothing appears to happen (except that the Function continues to > run successfully). > And based on your suggestion re: the DoEvents, I tried something else -- I > put a breakpoint at the beginning of the Function, and then *single-stepped* > through it. And the fields DID get updated, as they should!! So evidently > it must be related to what you said, but there must be more to it. Because > now I can get the form to display, but nothing updated in the fields. (Oh, > and I know that the command syntax is OK, because I can cut the lines that > update the fields, paste them into the Debug Windows, and execute them -- > and the fields get updated correctly.) > So any other suggestions as to what I might do to get the fields updated? > And if it helps, I'm not using Text boxes, but Labels, since I am only > really putting out informational messages, and don't want editable fields. > So I'm setting the Caption property of the various labels, rather than > putting text into a Text box. Don't know if that makes a difference, but > thought I'd mention it. > ------------------------------ > Frank D. Nicodem, Jr.
|
Sun, 17 Feb 2002 03:00:00 GMT |
|
 |
Clint Wal #5 / 6
|
 Problem bringing up a form from VBA module
On thing I would try is to do a form object Refresh command after each Doevents. Form1.Refresh or Form1.Repaint try that Clint
|
Mon, 18 Feb 2002 03:00:00 GMT |
|
 |
Frank D. Nicodem, Jr #6 / 6
|
 Problem bringing up a form from VBA module
Quote: > On thing I would try is to do a form object Refresh command after each > Doevents. > Form1.Refresh > or > Form1.Repaint
The Repaint did the trick! Mike, I don't know *why* the DoEvents alone didn't work. I would tend to agree with you that it should, especially since the *first* DoEvents did succeed in bringing up the complete form. But for some reason, changes to the Label fields wouldn't be reflected (visually). However, following each change with a Repaint took care of the problem! Thanks to both of you. ------------------------------ Frank D. Nicodem, Jr.
|
Mon, 18 Feb 2002 03:00:00 GMT |
|
|
|