Baldev singh
asked on
Progress bar in access form
Hi Experts,
I've got some codes for showing progress bar in access form and is working fine on the sample form but not getting it worked with my form. Actually I'm not able to fit it at right place. both code are attached in txt file. I will appreciate your help please...
Thx and nice day..
Baldev
I've got some codes for showing progress bar in access form and is working fine on the sample form but not getting it worked with my form. Actually I'm not able to fit it at right place. both code are attached in txt file. I will appreciate your help please...
Thx and nice day..
Baldev
I dont see any attachment.
ASKER
sorry if the file was not uploaded, actually a text file was attached. ok I m trying to attach it again.
ProgressBar.txt
ProgressBar.txt
You're missing part of the code:
Check out the video tutorial this code is taken from: https://www.youtube.com/watch?v=0SqcA9vIRs0
Dim holdPercComplete As Single
Private Sub UpdateProgress(CurrentItem As Long, TotalItems As Long, taskName As String)
Dim PercComplete As Single
Dim intWidth As Integer
Me.lblCurrentTask.Caption = taskName
'Validate data
If CurrentItem <= 0 Or TotalItems <= 0 Then
imgProgress.Width = 0
Exit Sub
End If
'Calculate the percentage complete
PercComplete = CurrentItem / TotalItems
If Int(PercComplete * 100) = Int(holdPercComplete * 100) Then
Exit Sub
End If
'Save it for comparison
holdPercComplete = PercComplete
'Calculate how wide to make the progress bar
If (PercComplete * 100) Mod 5 = 0 Then
intWidth = (BoxProgress.Width * PercComplete)
imgProgress.Width = intWidth
DoEvents 'or Me.Repaint
End If
End Sub
Check out the video tutorial this code is taken from: https://www.youtube.com/watch?v=0SqcA9vIRs0
Then you would use it like so:
Note: you can add steps or move then around.
Private Sub cmdUpdate_DblClick(Cancel As Integer)
Dim filepath As String
' first step
Call UpdateProgress(1, 4, "Starting...")
filepath = "\\SERVER\Tally.ERP9\Data\BANK-2016\LodgmentDetails-Export.xlsx"
If FileExist(filepath) Then
DoCmd.TransferSpreadsheet acImport, , "Export", filepath, True
DoCmd.OpenQuery "Del_Errors", acViewNormal
If IsNull(DLookup("[DateDeposit]", "newrecords")) Then
MsgBox "No New Data to import."
Else
' second step
Call UpdateProgress(2, 4, "Getting there...")
DoCmd.OpenQuery "updateStat", acViewNormal
DoCmd.OpenQuery "UpdateOldCode", acViewNormal
MsgBox "Records imported successfully."
End If
Else
MsgBox "File Not Found. Please check name and location."
End If
' third step
Call UpdateProgress(3, 4, "Almost finished...")
'DoCmd.OpenQuery "Del_Errors", acViewNormal
Dim SQLdelete As String
SQLdelete = "Delete * from Export"
DoCmd.RunSQL SQLdelete
' finished
Call UpdateProgress(4, 4, "Task complete")
End Sub
Note: you can add steps or move then around.
ASKER
Thank you very much dear. i'm really sorry for coming very late on it. I copied the code as you advised but it showing "compile error : sub or function not defined" and highlights "file exists". I may upload my file if you wish to see.
Error.JPG
Error.JPG
Hey, that's your code not mine...
Here, add this function:
Here, add this function:
Function FileExist(strDirectory As String, strFileName As String) As Boolean
With CreateObject("Scripting.FileSystemObject")
FileExist = .FileExists(strDirectory & "\" & strFileName)
End With
End Function
ASKER
You are correct dear. I really appreciate your help through out it.
I'm totally out now as it's showing me "compile error: argument not optional."
thanks in advance for any help.
I'm totally out now as it's showing me "compile error: argument not optional."
thanks in advance for any help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a ton !!! it works perfectly.
ASKER
Hi MacroShadow,
it works perfectly with the steps suggested. Being more greedy again, I wanted to increase the steps from 4 to 7 and stacked again. now the progress bar is showing only when task completes (not on steps). File is attached with the steps i added.
i don't know if I should stretch a question so long on the form, but really appreciate and much satisfy with the help received.
any help plzz
thanks again and hope i will get all the steps done :-)
StatusBar.txt
it works perfectly with the steps suggested. Being more greedy again, I wanted to increase the steps from 4 to 7 and stacked again. now the progress bar is showing only when task completes (not on steps). File is attached with the steps i added.
i don't know if I should stretch a question so long on the form, but really appreciate and much satisfy with the help received.
any help plzz
thanks again and hope i will get all the steps done :-)
StatusBar.txt
The code as you posted it should work.
If it doesn't ask a new question.
If it doesn't ask a new question.