Need Customized Msg For Error (1 Viewer)

Ashfaque

Student
Local time
Today, 08:58
Joined
Sep 6, 2004
Messages
732
Hi,

For some reason, I am displaying a particular employee's folder (kept on File Server) in Web Browser place on a form. This trigger run thru a combo from where I select employee.

So following code show his folder contains in Web Browser....this has no issue.
my other code line......
.........
............
.................
Me.FolderLocation = "\\inat\Admin HR\EMPLOYEES\" & "INAT-" & Me.CNo & " " & Me.CName & "\" & "PASSPORT" '"\

But when there is no folder on server, I need to display my own msg not the default one that says "Cant Find......Make Sure The Path Or Internet Address Is Correct"

Error handler is there but that I want my own msg for the browser.

Can someone let me know please....
 

onur_can

Member
Local time
Yesterday, 20:28
Joined
Oct 4, 2015
Messages
155
Have you created msgbox under the error handler?
 

Ashfaque

Student
Local time
Today, 08:58
Joined
Sep 6, 2004
Messages
732
Yes....as follows.. but still giving default msg

Me.FolderLocation = "\\inat\Admin HR\EMPLOYEES\" & "INAT-" & Me.CNo & " " & Me.CName & "\" & "PASSPORT" '"\

Me.WebBrowser156.Requery
Me.Refresh

Exit_CboSearchWarn_AfterUpdate:
Exit Sub

Err_CboSearchWarn_AfterUpdate:
MsgBox ("The Folder Has Not Yet Created For This Employee"), vbCritical, "Help"
' MsgBox Err.description
Resume Exit_CboSearchWarn_AfterUpdate
 

arnelgp

error reading drive A:
Local time
Today, 11:28
Joined
May 7, 2009
Messages
12,067
you can use Dir$() to check if the folder exists:

If Len(Dir$(Me!FolderLocation)) = 0 Then
'folder does not exists
msgbox "Folder, " & Me!FolderLocation & " does not exists. Please create the folder first."
Exit sub
End If
 

Gasman

Enthusiastic Amateur
Local time
Today, 04:28
Joined
Sep 21, 2011
Messages
7,906
Yes....as follows.. but still giving default msg

Me.FolderLocation = "\\inat\Admin HR\EMPLOYEES\" & "INAT-" & Me.CNo & " " & Me.CName & "\" & "PASSPORT" '"\

Me.WebBrowser156.Requery
Me.Refresh

Exit_CboSearchWarn_AfterUpdate:
Exit Sub

Err_CboSearchWarn_AfterUpdate:
MsgBox ("The Folder Has Not Yet Created For This Employee"), vbCritical, "Help"
' MsgBox Err.description
Resume Exit_CboSearchWarn_AfterUpdate
You would have to test for the actual error message number, surely? :unsure:
 

Ashfaque

Student
Local time
Today, 08:58
Joined
Sep 6, 2004
Messages
732

arnelgp

Thanks. The msg is active but after that default msg is still apearing...... I think the msg appearing from Web Browser as it didnt find the folder
 

arnelgp

error reading drive A:
Local time
Today, 11:28
Joined
May 7, 2009
Messages
12,067
Code:
Dim bolError
Me.FolderLocation = "\\inat\Admin HR\EMPLOYEES\" & "INAT-" & Me.CNo & " " & Me.CName & "\PASSPORT"


If Len(Dir$(Me!FolderLocation)) = 0 Then
    Goto Err_CboSearchWarn_AfterUpdate:
End If
bolError = True
Me.WebBrowser156.Requery
Me.Refresh

Exit_CboSearchWarn_AfterUpdate:
Exit Sub

Err_CboSearchWarn_AfterUpdate:
MsgBox ("The Folder Has Not Yet Created For This Employee"), vbCritical, "Help"
' MsgBox Err.description
If bolError Then
    Resume Exit_CboSearchWarn_AfterUpdate
Else
    Goto Exit_CboSearchWarn_AfterUpdate
End If
 

Ashfaque

Student
Local time
Today, 08:58
Joined
Sep 6, 2004
Messages
732

arnelgp


Thanks Arnel, but still default msg is appearing after customized msg.
 

Ashfaque

Student
Local time
Today, 08:58
Joined
Sep 6, 2004
Messages
732
I think we need to count the length till "\\inat\Admin HR\EMPLOYEES\ which is 25 and then length of "INAT-0000 " = 10 (including one space) then name of emp begins.

So this should go something like;

Dim BB As String

'Something to play on below 2-3 lines
BB = Len("\\inat\Admin HR\EMPLOYEES\" & "INAT-" & Me.CNo") - 26
If BB = Len(Me.CName) Then
MsgBox ("The Folder Has Not Yet Created For This Employee"), vbCritical, "Help"

Else
Me.FolderLocation = "\\inat\Admin HR\EMPLOYEES\" & "INAT-" & Me.CNo & " " & Me.CName & "\" & "PASSPORT" '"\ ' PATH TILL PASSPORT FOLDER IN EMP FOLDER

I trying but not yet success.....
 

Ashfaque

Student
Local time
Today, 08:58
Joined
Sep 6, 2004
Messages
732
I tried above way playing but still the default msg appears after customized msg :mad:
 

Attachments

  • Error.jpg
    Error.jpg
    40.6 KB · Views: 18

Ashfaque

Student
Local time
Today, 08:58
Joined
Sep 6, 2004
Messages
732
I suspect that browser's own error is triggering.....
 

isladogs

CID VIP
Local time
Today, 04:28
Joined
Jan 14, 2017
Messages
14,706
One easy way of determining which event is causing an error is to use code like this in the error handler

Code:
Err_Handler:
    MsgBox "Error " & err.Number & " in YourProcedureNameGoesHere: " & Err.Description
    Resume Exit_Handler
   
End Sub

If you use that approach in each procedure, it will cut out guesswork and save you time
 
Last edited:

isladogs

CID VIP
Local time
Today, 04:28
Joined
Jan 14, 2017
Messages
14,706
Sorry. My mistake. There were two consecutive '&' after err.Number.
I've corrected it above.

In addition you need to use your own names for the error handling labels
 

Ashfaque

Student
Local time
Today, 08:58
Joined
Sep 6, 2004
Messages
732
I noted that and had removed and thereafter only the above 0 error appeared.

If I am not wrong the error is being generated from browser itself.
 

isladogs

CID VIP
Local time
Today, 04:28
Joined
Jan 14, 2017
Messages
14,706
Add the error message to the Web browser control also!
 

isladogs

CID VIP
Local time
Today, 04:28
Joined
Jan 14, 2017
Messages
14,706
I'm suggesting adding code like that to the error handler section of every procedure.
It will save you time in the long run.
Start with any procedure associated with the Web browser control.
 

arnelgp

error reading drive A:
Local time
Today, 11:28
Joined
May 7, 2009
Messages
12,067
you already have an error handler on your previous post.

Code:
Dim bolError
On Error Goto Err_CboSearchWarn_AfterUpdate
Me.FolderLocation = "\\inat\Admin HR\EMPLOYEES\" & "INAT-" & Me.CNo & " " & Me.CName & "\PASSPORT"


If Len(Dir$(Me!FolderLocation)) = 0 Then
    Goto Err_CboSearchWarn_AfterUpdate:
End If
bolError = True
Me.WebBrowser156.Requery
Me.Refresh

Exit_CboSearchWarn_AfterUpdate:
Exit Sub

Err_CboSearchWarn_AfterUpdate:
MsgBox ("The Folder Has Not Yet Created For This Employee"), vbCritical, "Help"
' MsgBox Err.description
If bolError Then
    Resume Exit_CboSearchWarn_AfterUpdate
Else
    Goto Exit_CboSearchWarn_AfterUpdate
End If
 

Ashfaque

Student
Local time
Today, 08:58
Joined
Sep 6, 2004
Messages
732
Thanks Arnel...

Below is my complete code (including yours). My code is working perfectly with no error. I am triggering from after update of combo. But still the default msg is appearing. My requirement of path is till emp name so I little bit changed it which is error free.

Only I need to remove defaulf msg of Browser.

On Error GoTo Err_CboSearchWarn_AfterUpdate

Dim db As DAO.Database
Dim Rst, rs As DAO.Recordset
Dim fld As DAO.Field
Dim IMax
Dim TempCriteria As String

Set Rst = CurrentDb.OpenRecordset("Select * from T_IssuedWarnings Where WarningID=" & Me.CboSearchWarn.Column(0))

If Rst.EOF = False And Rst.BOF = False Then
Rst.Edit

For Each fld In Rst.Fields
Me(fld.name) = Rst(fld.name)
Next fld

Me.CmdSaveWarnLetter.Enabled = False
Rst.Close
Set Rst = Nothing

Me.TxtLatesRec = Empty
Me.TxtAbsentRec = Empty
Me.TxtWarnRec = Empty

Dim X, Y, z, ZZ, XX As Integer
If IsNull(CboSearchWarn.Value) Then Exit Sub

X = DCount("*", "T_IssuedWarnings", "Cno = " & CboSearchWarn.Column(1) & " and Criteria = 'LATES'")
Y = DCount("*", "T_IssuedWarnings", "Cno = " & CboSearchWarn.Column(1) & " and Criteria = 'ABSENT'")
z = DCount("*", "T_IssuedWarnings", "Cno = " & CboSearchWarn.Column(1) & " and Criteria = 'VIOLATIONS'")
ZZ = DCount("*", "T_IssuedWarnings", "Cno = " & CboSearchWarn.Column(1) & " and Criteria = 'MISCONDUCT'")

XX = DCount("*", "T_IssuedWarnings", "Cno = " & CboSearchWarn.Column(1) & " and Criteria = 'Forms!F_IsssuedWarnings!Criteria'")

Me.TxtLatesRec = "Total # Of LATES = " & X
Me.TxtAbsentRec = "Total # Of ABSENTS = " & Y
Me.TxtWarnRec = "Total # Of VIOLATIONS = " & z
Me.TxtMisCondRec = "Total # Of MISCONDUCT = " & ZZ

TxtTotalWarnings = "Total Wanrings: " & X + Y + z + ZZ
End If

Me.CmdUpdateWarnLett.Enabled = True

'The above code is working properly.


Dim bolError
'On Error GoTo Err_CboSearchWarn_AfterUpdate
Me.FolderLocation = "\\inat\Admin HR\EMPLOYEES\" & "INAT-" & Me.CNo & " " & Me.Cname

If Len(Dir$(Me!FolderLocation)) = 0 Then
GoTo Err_CboSearchWarn_AfterUpdate:
End If
bolError = True
Me.WebBrowser156.Requery
Me.Refresh

Exit_CboSearchWarn_AfterUpdate:
Exit Sub

Err_CboSearchWarn_AfterUpdate:
MsgBox ("The Folder Has Not Yet Created For This Employee"), vbCritical, "Help"
' MsgBox Err.description
If bolError Then
Resume Exit_CboSearchWarn_AfterUpdate
Else
GoTo Exit_CboSearchWarn_AfterUpdate
End If
 

Users who are viewing this thread

Top Bottom