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

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-14-2019, 04:40 PM   #16
Micron
AWF VIP
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 942
Thanks: 10
Thanked 195 Times in 185 Posts
Micron has a spectacular aura about Micron has a spectacular aura about
Re: Progress Bar in MS Access

Quote:
Without some data in the table the demo will not work.
With respect to your code I'd say that is sort of my point. The code shouldn't balk regardless if the reason is that there's no table data, or there is but the recordset is empty. A recordset may get populated every time for umpteen times that it's set - it only takes 1 anomaly for it to be empty, regardless of how many tables contain data.

I got in the habit of

If Not (rs.EOF And rs.BOF) Then

while others say if either is True, then there are no records thus one only needs to check for one or the other.

Micron is offline   Reply With Quote
The Following User Says Thank You to Micron For This Useful Post:
apr pillai (06-14-2019)
Old 06-15-2019, 01:41 PM   #17
gemma-the-husky
Super Moderator
 
gemma-the-husky's Avatar
 
Join Date: Sep 2006
Location: UK
Posts: 13,769
Thanks: 55
Thanked 1,022 Times in 988 Posts
gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all
Re: Progress Bar in MS Access

With any operation that may error, you need to include error handling.

I tend to count the records with a dcount("*","queryname") first. If there are no records, then I never open the recordset.


It may be more efficient to open the recordset, and do a movelast instead. I don't know, to be honest.

Code:
on error goto fail  'always!

recordcount = dcount("*","queryname")
if recordcount=0 then
   suitable message
   exit code
end if

set rs= openrecordset()
while not rs.eof
    ,,,
    ,,,
    rs.movenext
wend
rs.close
__________________
Dave (Male!)
Gemma was my dog

if a poster helps you, please click the scales at the bottom left of this posting, or use the thanks button alongside.
gemma-the-husky is offline   Reply With Quote
Old 06-15-2019, 02:55 PM   #18
Micron
AWF VIP
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 942
Thanks: 10
Thanked 195 Times in 185 Posts
Micron has a spectacular aura about Micron has a spectacular aura about
Re: Progress Bar in MS Access

Quote:
It may be more efficient to open the recordset, and do a movelast instead. I don't know, to be honest.
The potential problem with recordset count is that it can behave in one fashion for DAO and in anoither for ADO. An ADO recordset count can return a value of -1 Thus > 0 is not a foolproof test (or so Allen Browne says, and whatever he says is pretty much good enough for me). So, rather than code one way for ADO and another for DAO, you can't go wrong with testing If Not (rs.BOF And rs.EOF) Then because if both are true, there are no records regardless if ADO or DAO.

Then Albert Kalli (sp?) who is right up there with AB says you don't need to test for both, i.e. if one is true, the other is also. That's a new one for me and probably only applies when the rs has just been initialized as it is possible to MoveNext into EOF. I'll probably stick with my current habit, which is that if BOF and EOF are true, there are no records, thus don't move first, last, or do anything with that rs.

In the end, we all do what we think is right - until it isn't.

__________________
Sometimes I just roll my eyes out loud...
Windows 10; Office 365 (Access 2016)
Micron is offline   Reply With Quote
Old 06-17-2019, 03:00 PM   #19
axsprog
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
axsprog is on a distinguished road
Re: Progress Bar in MS Access

Has any of you used just a textbox on a form and used conditional formatting (it has an option for progress bar) and let that be the engine that drives the meter? Now I do not know how well it would work counting a hundred thousand records, but for value and progression representations for dashboards, and such , it's awesome.
axsprog is offline   Reply With Quote
Old 06-17-2019, 04:41 PM   #20
Micron
AWF VIP
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 942
Thanks: 10
Thanked 195 Times in 185 Posts
Micron has a spectacular aura about Micron has a spectacular aura about
Re: Progress Bar in MS Access

You're not saying you have done this are you? I'm trying to envision how you make a textbox information bar progress during some execution because the control has to be bound AFAIK, and what would you bind it to that can reflect an ever increasing number? Sounds intriguing but also sounds improbable.
__________________
Sometimes I just roll my eyes out loud...
Windows 10; Office 365 (Access 2016)
Micron is offline   Reply With Quote
Old 06-18-2019, 09:50 AM   #21
apr pillai
Newly Registered User
 
apr pillai's Avatar
 
Join Date: Jan 2005
Location: India
Posts: 677
Thanks: 1
Thanked 107 Times in 95 Posts
apr pillai is on a distinguished road
Send a message via AIM to apr pillai Send a message via Yahoo to apr pillai Send a message via Skype™ to apr pillai
Re: Progress Bar in MS Access

Quote:
Originally Posted by gemma-the-husky View Post

I tend to count the records with a dcount("*","queryname") first. If there are no records, then I never open the recordset.



It may be more efficient to open the recordset, and do a movelast instead. I don't know, to be honest.

It depends on what purpose we open the recordset for. If you attempt to take a count of records Immediately after opening the recordset the output will be 1. That means the recordset is not fully populated in memory.

To do that an rs.movelast is required before taking a count. On the SysCmd() case we need the total count of records for the initial call to the command. Subsequent calls needs the processed record count.

Yes, we all code differently taking it through the known route for faster delivery, till it is proved wrong or inefficient.


Sent from my iPhone using Tapatalk
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Learn MS-Access Tips and Tricks)

All responses are based on Access2003/2007
apr pillai is offline   Reply With Quote
Old 06-18-2019, 12:25 PM   #22
axsprog
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
axsprog is on a distinguished road
Re: Progress Bar in MS Access

i can't post links yet as I haveonly 6 and this makes 7 but if you search Spy dot com I mean Google for:


access vba conditional format databar as progress bar


you will some great articles for this


easiest way to have a progress bar without a progress bar Might take a little tweaking with recordcounts but I use them to show task progress on individual Projects we do.

axsprog is offline   Reply With Quote
Old 06-18-2019, 12:26 PM   #23
axsprog
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
axsprog is on a distinguished road
Re: Progress Bar in MS Access

the improbable becomes the probable
axsprog is offline   Reply With Quote
Old 06-18-2019, 02:39 PM   #24
Micron
AWF VIP
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 942
Thanks: 10
Thanked 195 Times in 185 Posts
Micron has a spectacular aura about Micron has a spectacular aura about
Re: Progress Bar in MS Access

Quote:
Originally Posted by axsprog View Post
the improbable becomes the probable
I look forward to your example for when the control containing the cf bar is unbound as I stated. That would be cool.
__________________
Sometimes I just roll my eyes out loud...
Windows 10; Office 365 (Access 2016)
Micron is offline   Reply With Quote
Old 06-18-2019, 06:55 PM   #25
axsprog
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
axsprog is on a distinguished road
Re: Progress Bar in MS Access

My post was clear - I said I (me) use it for certain things AND I did not know how it interacts with recordsets Also I don't use the syscommand for my users because they really don't look at it , they look at an hour glass or maybe a pop up modal form (where I run the code from) until finished. I used to do all the above but unless I do a heavy process dependent routine, I have found systems run so fast and connectivity and bandwidth so wide that users generally do not have to wait for anything However other than the one client I am converting to 365 frontend from an adp(first I imported into 2007) all of my clients are remote on Office 365/TerminalServices so performance is always spot on. I use the bars for displaying overall progress and performance, not as a realtime counter. But check out the articles if you have never used the data bar feature with the conditional formatting.
axsprog is offline   Reply With Quote
Old 06-19-2019, 02:57 AM   #26
gemma-the-husky
Super Moderator
 
gemma-the-husky's Avatar
 
Join Date: Sep 2006
Location: UK
Posts: 13,769
Thanks: 55
Thanked 1,022 Times in 988 Posts
gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all
Re: Progress Bar in MS Access

I have some processes that will take several minutes to complete, so I use an hourglass, a progress meter, and a auto-clearing msgbox to advise users to be patient at times.
__________________
Dave (Male!)
Gemma was my dog

if a poster helps you, please click the scales at the bottom left of this posting, or use the thanks button alongside.
gemma-the-husky is offline   Reply With Quote
Old 06-19-2019, 11:11 AM   #27
Micron
AWF VIP
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 942
Thanks: 10
Thanked 195 Times in 185 Posts
Micron has a spectacular aura about Micron has a spectacular aura about
Re: Progress Bar in MS Access

Quote:
Originally Posted by axsprog View Post
My post was clear.
No need to get bent out of shape. I read the article and it said the control has to be bound. Since you disagreed with me and stated that such use of a textbox is probable, I simply and politely asked you to show why it is not improbable as a meter.

Micron 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
Progress Bar In Ms Access 2003 cheer Forms 1 07-18-2017 01:01 AM
Progress Indicator using Access/VBA aman Modules & VBA 8 07-08-2014 03:51 AM
Access Progress bar for VBA processing? jonathanchye General 3 06-22-2011 06:56 AM
[SOLVED] MS Access Progress Bar drjez General 4 02-10-2005 09:01 AM
The progress bar in ms access benheaven1 Forms 3 12-23-2003 01:53 AM




All times are GMT -8. The time now is 11:08 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 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World