[AccessD] Raising errors...

Charlotte Foust cfoust at infostatsystems.com
Tue Aug 8 14:51:35 CDT 2006


Raising errors only bumps them up to the next level.  It's a somewhat
passive action.  You have to check for the raised error in the calling
routine.  Have you done that? 

Charlotte Foust

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bobby Heid
Sent: Tuesday, August 08, 2006 12:15 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Raising errors...

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

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list