Field widths based on control

ErinL

Registered User.
Local time
Today, 17:48
Joined
May 20, 2011
Messages
118
Hello everyone -

I am trying to find a way to set field's width to be based on a control on a form. I have a form that shows the progress of selection waves and there is a field called "Percentage Done" on which I want to based the width of a field called rctBar.

I found a thread that did this exact process on reports by creating a rectangle control and putting the following code in the OnFormat event of the Detail section of the report:

rctBar.Width = ([Percentage Done] / 100) * (1440 * 3)

This works perfect but only works in Print Preview, no other views.

I would prefer to use a form but could use a report too. The trick I have is that the form/report updates every 30 seconds to show the progression of the selection waves. When I am looking at the form in Form view or the report in Report view, the number fields update but the bar does not change widths to show the increase in "Percentage Done". When am looking at the report in Print Preview, it doesn't update every 30 seconds.

Can anyone tell me if this is possible to do in a form or in the Report View of a report?

Thank you in advance.
 
Have you tried using a progress bar control on the form instead?
 
Have you thought about using text instead. You can use the pipe symbo, i.e. |, and the String() function to indicate the percentage of completion.

The String() function works this way:
Code:
String(10, "|")
will give:
||||||||||
So as you can see the String() function returns the pipe symbol 10 times as indicated in the first parameter.
 
Thank you r.harrison and vbaInet for you suggestions.

Since I was not familiar with creating progress bars, I have been looking at numerous posts and see that it involves a lot of code which I am a beginner at to say the least.

Would you be able to help me with that?

I am not sure the pipe symbol option would work since I need it to show more than just a rounded 20%, 40%, etc. I would need the progress bar to reflect the number in the Percentage Done field whether it's 20, 21, 22, 67, etc.

Thank you both again for your suggestions and any assistance on the code writing would be much appreciated.
 
Hi ErinL,

I've attached a sample file with a progressbar control. Any questions just ask.

Rich.
 

Attachments

Hi Rich -

Thanks for the sample of the progress bar. Now that I see it in action, I'm afraid that isn't what I had in mind.

I did find something that worked though. I put the following code in the OnCurrent event of the form:

Me.boxInside.Width = ([Percentage Done] / 100) * (1440 * 3)

I gave the rectangle called boxInside a green background color. When the numbers update in the table, the width adjusts just the way I want it to. However (you know there had to be one of those :p), it only reflects the number in the first record on the form. Each record in the form is a different wave and has a different Percentage Done but all the fields reflect only the first records Percentage Done amount.

Would you know why it won't relate to the number in the Percentage Done field of wach record independently or how I can get it to do that?

Hopefully this makes sense. If not, I can try to attach the database.

Thanks again for your help.
 
All I can think of would be to have several 'progress boxes' relating to each item then maybe an extra one which will be an overall progress.
 
I am not sure the pipe symbol option would work since I need it to show more than just a rounded 20%, 40%, etc. I would need the progress bar to reflect the number in the Percentage Done field whether it's 20, 21, 22, 67, etc.
What do you mean by whole numbers? The String() function uses non-decimal numbers.
 
This works perfect but only works in Print Preview, no other views.

FYI:

For the Report View of a report, you would put the same code into the ON PAINT event of the same section where the code that worked for Print Preview worke.d
 
I gave the rectangle called boxInside a green background color. When the numbers update in the table, the width adjusts just the way I want it to. However (you know there had to be one of those :p), it only reflects the number in the first record on the form. Each record in the form is a different wave and has a different Percentage Done but all the fields reflect only the first records Percentage Done amount.
It's a continuous form right? Then any calculations need to be done in the Control Source property.
 
Thank you to all who replied.

With your great suggestions, I have come up with two different ways of presenting the data. Both of which look very professional.

Thank you all for your assistance and patience! :)
 

Users who are viewing this thread

Back
Top Bottom