Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-11-2008, 08:28 AM   #1
TUSSFC
Registered User
 
Join Date: Apr 2007
Posts: 57
Thanks: 0
Thanked 2 Times in 2 Posts
TUSSFC is on a distinguished road
Progress bar within a form

Wasn't sure whether to post this here or in the forms cat. As it involves code, I chose here.

I'm trying to simulate a progress bar within a form using a textfield. I've found the following code on t'interweb but cannot get it to work. When I click the command button to start the progress bar nothing happens.

On the form load event I have:

Code:
Private Sub Form_Load()
 
Progress.Width = 0
Progress.BackColor = 16711680
End Sub
On the command buttons click event I have:

Code:
Private Sub b_Go_Click()
 
Dim i As Integer, x As Double
Dim num As Integer, start As Double
 
num = 1000
x = 6237 / num
 
For i = 1 To num
 
start = Timer
Do While Time < start + 0.02
DoEvents
Loop
 
Progress.Width = i * x
 
Next i
 
End Sub
num will, at some point, be the number of records which are querying but for interim is a dummy value for the sake of testing the thing works.

x is the width of the textbox (11cm) converted into twips.

Any ideas where I'm going wrong? No errors when debugging and I don't think I need any references for this to work.

Thanks.

TUSSFC is offline   Reply With Quote
Old 09-11-2008, 08:46 AM   #2
TUSSFC
Registered User
 
Join Date: Apr 2007
Posts: 57
Thanks: 0
Thanked 2 Times in 2 Posts
TUSSFC is on a distinguished road
Re: Progress bar within a form

Doh ... typo.

Do While Time < start + 0.02

should be

Do While Timer < start + 0.02
TUSSFC is offline   Reply With Quote
Old 09-11-2008, 02:37 PM   #3
RuralGuy
AWF VIP
 
RuralGuy's Avatar
 
Join Date: Jul 2005
Location: @ 8300' in the Colorado Rockies
Posts: 13,815
Thanks: 7
Thanked 309 Times in 299 Posts
RuralGuy is just really nice RuralGuy is just really nice RuralGuy is just really nice RuralGuy is just really nice RuralGuy is just really nice
Re: Progress bar within a form

Instead if troubleshooting what you have, I'm going to offer a link to other progress bars you can use. http://www.accessmvp.com/JConrad/acc...gressbars.html

__________________
(RG for short) aka Allan Bunch Previous MS Access MVP acXP, ac07, ac10, ac13 - WinXP Pro, Win7 Pro, Win10 Pro
Please post back to this Forum so all may benefit.
Teaching is not filling a bucket but lighting a fire.
RuralGuy is offline   Reply With Quote
Old 09-12-2008, 03:56 AM   #4
TUSSFC
Registered User
 
Join Date: Apr 2007
Posts: 57
Thanks: 0
Thanked 2 Times in 2 Posts
TUSSFC is on a distinguished road
Re: Progress bar within a form

Hi

I managed to get the progress bar working with the typo amendment above.

However ...

I now need that code to execute at the same time as executing an append query.

The "num = 1000" value reflects the number of records in the query recordset.

There is a simple command button on a form ... when the user clicks it needs to run the append whilst executing the progress bar to indicate the progress.

Sounds simple .. but I can't work out how to construct the onClick VBA to run the two actions simultaneously :-s
TUSSFC is offline   Reply With Quote
Old 09-12-2008, 06:21 AM   #5
RuralGuy
AWF VIP
 
RuralGuy's Avatar
 
Join Date: Jul 2005
Location: @ 8300' in the Colorado Rockies
Posts: 13,815
Thanks: 7
Thanked 309 Times in 299 Posts
RuralGuy is just really nice RuralGuy is just really nice RuralGuy is just really nice RuralGuy is just really nice RuralGuy is just really nice
Re: Progress bar within a form

Access is single threaded and will only execute one thread at a time. Sorry.
__________________
(RG for short) aka Allan Bunch Previous MS Access MVP acXP, ac07, ac10, ac13 - WinXP Pro, Win7 Pro, Win10 Pro
Please post back to this Forum so all may benefit.
Teaching is not filling a bucket but lighting a fire.
RuralGuy is offline   Reply With Quote
Old 09-12-2008, 06:26 AM   #6
KenHigg
Registered User
 
Join Date: Jun 2004
Posts: 13,309
Thanks: 8
Thanked 155 Times in 129 Posts
KenHigg has a spectacular aura about KenHigg has a spectacular aura about
Re: Progress bar within a form

If a progress bar is needed bad enough you can append via a recordset and put code in the shows progress...
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

ken

“You don’t learn to walk by following rules. You learn by doing, and by falling over.”
KenHigg is offline   Reply With Quote
Old 11-30-2008, 04:19 PM   #7
DreamGenius
Annoying Questionner
 
DreamGenius's Avatar
 
Join Date: Jul 2004
Location: Merstham, Surrey, UK
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
DreamGenius is on a distinguished road
Send a message via MSN to DreamGenius Send a message via Skype™ to DreamGenius
Re: Progress bar within a form

This thread has gotten me 90% to the solution to my problem, but I've fallen at the last hurdle.

My form has an On Load event which:
  1. Updates an Action Caption
  2. Calls a Function for that Action
  3. Updates the Progress Bar by 10%
  4. Updates a Status Caption
There are 10 steps in total, and each function hands control back to the form before the next is called, so the form should update but it doesn't, until the end.

Clue?

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
: Learning lots, fast!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
DreamGenius is offline   Reply With Quote
Old 11-30-2008, 04:23 PM   #8
boblarson
Smeghead
 
boblarson's Avatar
 
Join Date: Jan 2001
Location: Oregon, USA
Posts: 32,068
Thanks: 97
Thanked 1,817 Times in 1,575 Posts
boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold
Re: Progress bar within a form

Put in

DoEvents

prior to starting the function call
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
boblarson is offline   Reply With Quote
Old 11-30-2008, 04:23 PM   #9
RuralGuy
AWF VIP
 
RuralGuy's Avatar
 
Join Date: Jul 2005
Location: @ 8300' in the Colorado Rockies
Posts: 13,815
Thanks: 7
Thanked 309 Times in 299 Posts
RuralGuy is just really nice RuralGuy is just really nice RuralGuy is just really nice RuralGuy is just really nice RuralGuy is just really nice
Re: Progress bar within a form

Put in some DoEvents to give Access time to update the other form.

__________________
(RG for short) aka Allan Bunch Previous MS Access MVP acXP, ac07, ac10, ac13 - WinXP Pro, Win7 Pro, Win10 Pro
Please post back to this Forum so all may benefit.
Teaching is not filling a bucket but lighting a fire.
RuralGuy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing data from child form to the original form when both forms are open Mr_Si Modules & VBA 3 12-08-2007 11:57 AM
Splitted MDB created problem with FindAsYouType Gilfdz Modules & VBA 1 11-13-2007 03:14 AM
Error - "The object doesn't contain the Automation object "ExperationDialog" molnerr Reports 6 09-13-2007 01:39 PM
Progress Bar ? spacepro General 3 02-28-2003 02:54 PM
Progress bar in form Autoeng General 3 10-14-2002 01:44 PM




All times are GMT -8. The time now is 12:40 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World