Progress Meter (Updating Form Labels In Form View)

I have made several scripts using VB that process various data in MSAccess- check some boxes here, add notes to this text box, and so on based on conditions from a query. They all work exactly how I want them to, but some of them run for a rather long time and I would like to be able monitor the progress of the scripts.

My first thought was to create a Form right before the process starts and after every iteration of the process, update a label on the form that says, "12 out of 99,456 records processed." or possibly even draw a small blue rectangle and keep increasing the size of it to illustrate the progress like other programs often do.

I have relatively little experience in VB programming, but I know this would be a piece of cake in Java. When I tried implementing this in VB I found that I can't make any modifications to a Form while in Form View. Is there a way around this?

I also considered using a TextBox (surely this can be changed in FormView) and disguising it as a Label since I think TextBoxes look really tacky to display info that can't be modified. I ran into a problem here too, though. Here's what I did:

I get a: Run-time error '2467' Application-defined or object-defined error on the last line listed here.

Surely there is someone out there who has done this kind of thing before, and surely there is a way to implement this. I'm very close to scrapping everything I've done using the MS Access VB and just starting over with the front end with a platform that allows more control. Am I getting frustrated because I don't know what I'm doing or is it because MS VB is just not very flexible?

You cannot create or delete controls if the formis not in design view. Most other properties can be changed while the form is in any view.

Just create a label on the form manually. Save the form and then change the label's Caption property in code.

VBA is extremely flexible, but it has a different design methodology from Java. More or less anything that can be achieved in any event dirven, design language can be achieved in VBA but creating controls on the fly is something that you don't generally do with VBA. You usually use pre-created controls.

If you need a control on the form to be displayed under certain circumstances, create the control in Design view, giving it a FALSE value for the Visible property. This gives you the opportunity to set the value of the control before the user sees it, and to determine if and when the user will see it through code. This is the closest you will get to dynamic controls.

If you would like some examples, create a switchboard in Access using the Switchboard Manager utility, and examine the code it generates.

I'm awarding the points to shanesuebsahakarn because the solution to my problem was contained in that reply. The code that I posted was not working because I had not yet saved the form, and apparently you can't change the Captions on a label that has not yet been saved.

I still don't think VB is very flexible. Java is much more consistent about how to create and update objects and VB is extremely restrictive in that you can't add controls to existing forms. VB just doesn't seem intuitive to me. I feel like I have to look up somebody else's code to learn how to do anything. For example, to create a new form with a control on it, I would assume you could just do this:

Dim newForm as Form
Dim newControl as Control

Set newForm = new Form
Set newControl = new Control
newForm.addControl(newControl)

But that won't work at all. You have to use Application.CreateControl() to make the control. What's the point of the 'new' keyword if you can't universally create a new object with it? Some objects you can and some you can't. If it were consistent then the learning curve wouldn't be nearly so steep.

Again, it's a design methodology and understanding. The New keyword does work with forms, but it is used to create a new *instance* of an *existing object*. There should almost never be a situation where you ever need to create a form "on the fly". The keywords are not necessarily analogous to an action you would perform in design view.

Language and application design environments don't all work in the same way, and you can't expect them to. Many of us here could achieve almost anything in VBA that can be achieved with other languages and you'll learn the appropriate methods as you progress with it.

Featured Post

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …

Learn how to number pages in an Access report over each group.
Activate two pass printing by referencing the pages property:
Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

Using Microsoft Access, learn some simple rules for how to construct tables in a relational database.
Split up all multi-value fields into single values:
Split up fields that belong to other things into separate tables:
Make sure that all record…