Progress Bar

P

Peter Kinsman

I am persevering with a program to convert a form from VB6 to Access. The
form I am working on has a MSComctlLib.ProgressBar and a VB.Timer.
I can add the ProgressBar to the form manually and then alter the
parameters, but does anyone know how to add it in VBA please?
As a Timer control is invisible, can I use the OnTimer event of the form
iteslf instead?

Many thanks

Peter Kinsman
 
D

Douglas J. Steele

I'm not sure why you'd want to add the progress bar using VBA. Are you
saying that you're intending to add it each time you need it, and delete it
when you're done? That's a bad idea: there's a lifetime limit of 754
controls on a form, so if you're constantly adding and deleting controls,
you're eventually reach the limit. Simply put it on the form and toggle its
visibility.

As to the Timer, there's no need for a timer control in Access. Set the
form's TimerInterval, and put the code in its On Timer event.
 
P

Peter Kinsman

I am trying to convert a form from VB6 to Access. Because I do not know the
syntax of the VBA equivalent to
Set pb = Forms(FormNo).Controls.Add("MSComctlLib.ProgCtrl.1", ctlName,
True)
then I would have to convert what I can and then add the missing controls
by hand, setting their size and position to the values in the original VB6
code. Having done this, I would save the form and it would hopefully not
need to be changed again.

Peter
 
D

Douglas J. Steele

With the form open in design view, select Insert | ActiveX Control from the
menu bar, then scroll through the list of available controls until you find
the entry for the Microsoft ProgressBar control.
 
P

Peter Kinsman

I have already done that. What I need is the VBA code to be used when I
encounter a Progress Bar in the VB6 file that I am converting.

Peter
 
D

Douglas J. Steele

You simply set a reference to the control you added on the form.

Set pb = Me![NameOfProgressBarControl]
 
P

Peter Kinsman

Lets go back to the beginning.
I am using VBA to create a new form based on an existing VB6 program.
Labels, TextBoxes and CommandButtons I am OK with, but because the
ProgressBar is a CustomControl, CreateControl won't work because there is no
intrinsic constant for the control type. What I am looking for is the VBA
code to add a Custom Control.

Peter

Douglas J. Steele said:
You simply set a reference to the control you added on the form.

Set pb = Me![NameOfProgressBarControl]

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Peter Kinsman said:
I have already done that. What I need is the VBA code to be used when I
encounter a Progress Bar in the VB6 file that I am converting.

Peter
 
D

Douglas J. Steele

Sorry, now I understand what you're looking for.

One of the constants you can specify for controltype in the CreateControl
function

CreateControl(formname, controltype[, section[, parent[, columnname[, left[,
top[, width[, height]]]]]]])

is acCustomControl. To be honest, I've never tried using it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Peter Kinsman said:
Lets go back to the beginning.
I am using VBA to create a new form based on an existing VB6 program.
Labels, TextBoxes and CommandButtons I am OK with, but because the
ProgressBar is a CustomControl, CreateControl won't work because there is
no intrinsic constant for the control type. What I am looking for is the
VBA code to add a Custom Control.

Peter

Douglas J. Steele said:
You simply set a reference to the control you added on the form.

Set pb = Me![NameOfProgressBarControl]

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Peter Kinsman said:
I have already done that. What I need is the VBA code to be used when I
encounter a Progress Bar in the VB6 file that I am converting.

Peter

With the form open in design view, select Insert | ActiveX Control from
the menu bar, then scroll through the list of available controls until
you find the entry for the Microsoft ProgressBar control.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I am trying to convert a form from VB6 to Access. Because I do not
know the syntax of the VBA equivalent to
Set pb = Forms(FormNo).Controls.Add("MSComctlLib.ProgCtrl.1",
ctlName, True)
then I would have to convert what I can and then add the missing
controls by hand, setting their size and position to the values in the
original VB6 code. Having done this, I would save the form and it
would hopefully not need to be changed again.

Peter

message I'm not sure why you'd want to add the progress bar using VBA. Are
you saying that you're intending to add it each time you need it, and
delete it when you're done? That's a bad idea: there's a lifetime
limit of 754 controls on a form, so if you're constantly adding and
deleting controls, you're eventually reach the limit. Simply put it
on the form and toggle its visibility.

As to the Timer, there's no need for a timer control in Access. Set
the form's TimerInterval, and put the code in its On Timer event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I am persevering with a program to convert a form from VB6 to Access.
The form I am working on has a MSComctlLib.ProgressBar and a
VB.Timer.
I can add the ProgressBar to the form manually and then alter the
parameters, but does anyone know how to add it in VBA please?
As a Timer control is invisible, can I use the OnTimer event of the
form iteslf instead?

Many thanks

Peter Kinsman
 
T

Tony Toews [MVP]

Peter Kinsman said:
I am persevering with a program to convert a form from VB6 to Access. The
form I am working on has a MSComctlLib.ProgressBar and a VB.Timer.
I can add the ProgressBar to the form manually and then alter the
parameters, but does anyone know how to add it in VBA please?
As a Timer control is invisible, can I use the OnTimer event of the form
iteslf instead?

Don't use the progress bar control as you'll run into distribution
problems sooner or later with any controls especially with MS
controls.

Instead use some rectangle controls on a form. See the Progress Bars
and Microsoft Access page at
http://www.granite.ab.ca/access/progressbar.htm for more info.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top