Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Progress Bar

Status
Not open for further replies.

adamroof

Programmer
Nov 5, 2003
1,107
US
Am i even close? my bar stays gray whole time...
This is the button click event...
Code:
    Me.myProgBar.Max = 1000
    Me.myProgBar.Min = 1
    Me.myProgBar.Value = i
    With rst
    Do Until rst.EOF
        If IsNull(rst!ContactEmail) Then
            rst.MoveNext
        Else
        Set objEmail = objOutlook.CreateItem(olMailItem)
            objEmail.To = rst!ContactEmail
            objEmail.subject = subject
            objEmail.HTMLBody = strBody
            objEmail.Send
            Me.myProgBar.Value = i + 1
        rst.MoveNext
        End If
    Loop
 
Hallo,

I'm not familiar with the control, but try replacing:
Me.myProgBar.Value = i + 1
with
Me.myProgBar.Value = Me.myProgBar.Value + 1
and see what happens.

The problem in your code (I think) is that your i value is never updated. Or if that's not the problem, it's certainly going to be a problem later :)

- Frink

Just a thought, do you have to 'Show' the control, or is just changing the value enough to display it?
 
Hi,

one issue you may have is if your record set is greater than 1000 it will casue an error or if you only have a small number of records it will hardly register on the progress bar - one solution is to set the max value of your prog bar to the count of records in the recordset...
Code:
    Me.myProgBar.Max = 1000
    Me.myProgBar.Min = [highlight]0
    i = 0    ' integer is initailised as 0 anyway but...
    rst.MoveLast    ' have to move to the end of recordset to get count
    rst.MoveFirst    ' move back to first record
    Me.myProgBar.Value = rst.RecordCount[/highlight]
    With rst
    Do Until rst.EOF
        [highlight]i = i + 1[/highlight]
        If IsNull(rst!ContactEmail) Then
            rst.MoveNext
        Else
        Set objEmail = objOutlook.CreateItem(olMailItem)
            objEmail.To = rst!ContactEmail
            objEmail.subject = subject
            objEmail.HTMLBody = strBody
            objEmail.Send
            Me.myProgBar.Value = i
        rst.MoveNext
        End If
    Loop

HTH, Jamie
FAQ219-2884
[deejay]
 
Ignore the last post it was wrong!
Code:
Me.myProgBar.Min = [highlight]0
    i = 0    ' integer is initialised as 0 anyway but...
    rst.MoveLast    ' have to move to the end of recordset to get count
    rst.MoveFirst    ' move back to first record
    Me.myProgBar.Max = rst.RecordCount[/highlight]
    With rst
    Do Until rst.EOF
        [highlight]i = i + 1[/highlight]
        If IsNull(rst!ContactEmail) Then
            rst.MoveNext
        Else
        Set objEmail = objOutlook.CreateItem(olMailItem)
            objEmail.To = rst!ContactEmail
            objEmail.subject = subject
            objEmail.HTMLBody = strBody
            objEmail.Send
            Me.myProgBar.Value = [highlight]i[/highlight]
        rst.MoveNext
        End If
    Loop

HTH, Jamie
FAQ219-2884
[deejay]
 
Thanks! ill give it a try and letcha know...There are about 3600 emails being generated (subscription only, not spam!)
Food for thought, can i set percentages? or is it another can of worms?
 
hi,

to set the progress bar to percent, first set max to 1 then switch
Me.myProgBar.Value = i
to
Me.myProgBar.Value = i / rst.recordcount
- though it might be an idea to assign rst.recordcount to a variable...

HTH, Jamie
FAQ219-2884
[deejay]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top