Method 'Value' of '_CustomControl' failed (-2147417848)

F

falbrech_www

Hello all!

In my access application I implemented a progress bar. Within a loop I
am calculating the actual percentage of progress. The formula is as
follows:

Forms!frm_progress.progressbar.Value = vOffset + (vProcessedRecords
*100 / vNumberOfRecords)

This works for most of my cases (vNumberOfRecords < 100), but if the
number of records increases to 14000 I got the error "Method 'Value' of
'_CustomControl' failed (-2147417848)". This error seems to appear
randomly!

One situation where it appeared was the following values:

Forms!frm_progress.progressbar.Value = 0 + (347 * 100 / 14257)

whereas Forms!frm_progress.progressbar.Max = 100


Any ideas what goes wrong here?

Thanks in advance.
Florian
 
R

Ron Hinds

Your calculation is resulting in a number too complicated for the
ProgressBar control. In fact, I get a Runtime Error 6 (overflow) when I type
this into a Debug window:

?0 + (347 * 100 / 14257)

Try this instead:

Forms!frm_progress.progressbar.Value = CSng(vOffset + (vProcessedRecords /
vNumberOfRecords) * 100)
 
F

Florian Albrecht

Hi Ron,
Forms!frm_progress.progressbar.Value = CSng(vOffset + (vProcessedRecords /
vNumberOfRecords) * 100)

OK, that's it! Thanks for your help! Anyway, I am still wondering why
this happens not everytime but only from time to time... Maybe this one
of those secrets we never get to know.

bye,
Florian
 

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