Bobby Heid
bheid at appdevgrp.com
Tue Aug 8 14:14:35 CDT 2006
I tried to find information in the archives but could not.
I have a class that I am using to handle the opening of databases and one of
the opens a database and returns a database variable. This works well.
In the original code, there was error handling in place to handle 'database
is opened exclusively by someone...', and other errors. So in replacing the
opendatabase call with my class call, I would like the class to raise any
errors so that it propagates back to the calling function.
There are several older passwords that I have to keep track of.
I tried something like this:
Public Function OpenDB(ByVal strDBName As String, ByVal bOpenExclusive As
Boolean, ByVal bRO As Boolean) As Database
Dim db As Database
Dim i As Long
On Error Resume Next
Set OpenDB = Nothing 'init the db return value
For i = 0 To NUMPWS - 1
Set db = Workspaces(0).OpenDatabase(strDBName, bOpenExclusive, bRO,
";pwd=" & mstrPW(i))
If Err.Number = 0 Then 'if =0 then good open
Set OpenDB = db
Exit For
End If
If Err.Number <> 3031 Then 'some error other than invalid pw
Err.Raise Err.Number, "clsPW.OpenDB", Err.Description
Else
'if we're on the last pw, and it is invalid, raise an error
If i = NUMPWS - 1 Then 'last one
Err.Raise 3031, "clsPW.OpenDB", "Invalid password"
End If
End If
Next i
Proc_Exit:
Exit Function
End Function
It executes the err.raise statement as I expected, but nothing happens. Am
I misunderstanding the raise event?
Thanks,
Bobby